PDA

View Full Version : How to update command object in AbstractWizardFormController?


wallance
Apr 22nd, 2006, 10:05 PM
I have a controller that extends AbstractWizardFormController like this:

public class EditGroupWizardController extends AbstractWizardFormController {
...
protected void postProcessPage(HttpServletRequest request, Object command,
Errors errors, int page) throws Exception {
log.debug("postProcessPage()|page = " + page );
log.debug("checkValue = " + request.getParameter("checkValue"));

if (page == 0 && request.getParameter("checkValue") != null) {
// Get all selected users
String checkValue = (String) request.getParameter("checkValue");
String[] userIdList = checkValue.split(",");
log.debug("checkValue = " + checkValue
+ "|userIdList.length = " + userIdList.length);
// Delete all selected users

for (int i = 0; i < userIdList.length; ++i) {
log.debug("seclected user = " + userIdList[i]);
User user = getAppManager().getUserManager().getUserById(
Integer.parseInt(userIdList[i]));
((Group)command).getUsers().remove(user);
}
//Output all users in group
Iterator it = ((Group)command).getUsers().iterator();
while(it.hasNext()) {
User tmpUser = (User) it.next();
log.debug("user = " + tmpUser.getUserName());
}
}
if (page == 1 && request.getParameter("Btn_Add") != null) {

}
}
...
}

and my bean config:

<bean id="editGroupWizardController" class="org.hxmt.hcmp.control.EditGroupWizardController">
<property name="appManager">
<ref bean="appManager"/>
</property>
<property name = "sessionForm">
<value>true</value>
</property>
<property name="commandName" value="group" />
<property name="commandClass" value="org.hxmt.hcmp.domain.Group" />
<property name="pages">
<list>
<value>editGroup</value>
<value>addUserGroup</value>
<value>successGroup</value>
</list>
</property>
</bean>

Here comes the problem: when I try to modify the command object in postProcessPage()(red lines), that is, I remove some users from group in postProcessPage(), it doesn't work. The "group" object remain the same. I don't know why, can anyone help me?