So I created my own class that extends SimpleFormController and overrides the formBackingObject method like this:
Code:
protected Object formBackingObject(HttpServletRequest request) throws Exception {
if(isSessionForm()) {
HttpSession session = request.getSession();
log.debug("session form attribute is: "+getFormSessionAttributeName());
Object object = session.getAttribute(getFormSessionAttributeName());
if(object != null) {
log.debug(getFormSessionAttributeName()+"="+object);
return (TestCommandObject)object;
} else {
log.debug(getFormSessionAttributeName()+" is null");
}
}
return createCommand();
}
The first time I issue a GET request to the form, the object is null, as expected:
Code:
10886 - DEBUG - MySimpleFormController().formBackingObject:17 - session form attribute is: test.MySimpleFormController.form.command
10886 - DEBUG - MySimpleFormController().formBackingObject:23 - test.MySimpleFormController.form.command is null
But after I enter something, submit the form, and then issue another GET request, the object is still null:
Code:
38784 - DEBUG - MySimpleFormController().formBackingObject:17 - session form attribute is: test.MySimpleFormController.form.command
38784 - DEBUG - MySimpleFormController().formBackingObject:23 - test.MySimpleFormController.form.command is null
Why is it null? Shouldn't the controller save the command object to the session the first time I submit the form?