I just realized that the value of my hidden property is being read correctly by the ActionForm, however the selection box is still being reset (null in ActionForm).
Here is my ActionForm class:
package com.sys.harps.usermanagement;
/*
* RoleForm.java
*
* Created on January 14, 2008, 2:10 PM
*/
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
/**
*
* @author ssood
* @version
*/
public class RoleForm extends org.apache.struts.action.ActionForm {
private
String[] allUsers;
private String[] allRoles;
private String[] userRoles;
private String[] privileges;
private String[] rolePrivileges;
private String command;
private boolean emailOption;
public String[] getPrivileges() {
return privileges;
}
public void setPrivileges(String[] privileges) {
this.privileges = privileges;
}
public String[] getRolePrivileges() {
return rolePrivileges;
}
public void setRolePrivileges(String[] rolePrivileges) {
this.rolePrivileges = rolePrivileges;
}
public boolean getEmailOption() {
return emailOption;
}
public void setEmailOption(boolean emailOption) {
this.emailOption = emailOption;
}
/**
* @return
*/
public String[] getUserList_id() {
return allUsers;
}
/**
* @param string
*/
public void setUserList_id(String[] allUsers) {
this.allUsers = allUsers;
}
/**
* @return
*/
public String[] getRolesList_id() {
return allRoles;
}
/**
* @param string
*/
public void setRolesList_id(String[] allRoles) {
this.allRoles = allRoles;
}
/**
* @return
*/
public String[] getUserRoleList_id() {
return userRoles;
}
/**
* @param string
*/
public void setUserRoleList_id(String[] userRoles) {
this.userRoles = userRoles;
}
public String getCommand() {
return command;
}
public void setCommand(String command) {
this.command = command;
}
/**
*
*/
public RoleForm() {
super();
// TODO Auto-generated constructor stub
}
public ActionErrors validateRemove(ActionMapping mapping, HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if (getUserRoleList_id() == null || getUserRoleList_id().length < 1) {
errors.add("removeUser", new ActionError("error.remove.required"));
} else if(getUserRoleList_id().length == 1 && getUserRoleList_id()[0].equals("")) {
errors.add("removeUser",new ActionError("error.invalid"));
}
return errors;
}
public ActionErrors validateAdd(ActionMapping mapping, HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if (getUserList_id() == null || getUserList_id().length < 1) {
errors.add("addUser", new ActionError("error.add.required"));
} else if(getUserList_id().length == 1 && getUserList_id()[0].equals("")) {
errors.add("addUser",new ActionError("error.invalid"));
}
return errors;
}
public ActionErrors validateRemoveRole(ActionMapping mapping, HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if (getRolesList_id() == null || getRolesList_id().length < 1) {
errors.add("removeRole", new ActionError("error.removeRole.required"));
} else if(getRolesList_id().length > 1) {
errors.add("removeRole", new ActionError("error.removeRole.one"));
/* Checks if selection is a predefined role, if so this cannot be removed. */
} else if(getRolesList_id()[0].equals("2")) {
errors.add("removeRole", new ActionError("error.removeRole.cannotRemove"));
}
return errors;
}
public void reset() {
allUsers = null;
userRoles = null;
allRoles = null;
}
}
Thanks again for any help!