AbstractWizardFormController and abstract HandleRequestInternal
Hello,
I am attempting to familiarize myself with the AbstractWizardFormController. I have a bean (let's call it SampleBean) with 3 properties (2 strings and 1 int). I have successfully created a SimpleFormController to edit the bean and save changes to it. Now I would like to try making a 3 step process which updates 1 property at a time. I have the following in my dispatcher-servlet.xml:
Code:
<bean id="wizardController" class="com.example.WizardCreate">
<property name="pages">
<list>
<value>wizard0</value>
<value>wizard1</value>
<value>wizard2</value>
</list>
</property>
<property name="commandName" value="WizardBean"/>
<property name="commandClass" value="com.example.SomeBean"/>
<property name="s" ref="someOtherBean" />
<property name="validators">
<list>
<ref bean="sbValidator"/>
</list>
</property>
</bean>
<bean id="someOtherBean" class="com.example.SomeBeanImpl" scope="session">
<property name="s2" value="test non default value"/>
<aop:scoped-proxy proxy-target-class="false" />
</bean>
wizard0.jsp, wizard1.jsp, and wizard2.jsp all exist within /WEB-INF/classes/ and are appropriately resolved when I access them within a test controller.
I have created a class, com.example.WizardController that extends AbstractWizardFormController. However, I am forced to implement these methods:
Code:
public class WizardCreate extends AbstractWizardFormController {
private SomeBean s;
@Override
protected ModelAndView processFinish(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
throw new UnsupportedOperationException("Not supported yet.");
}
}
I have omitted the getters/setters for SomeBean, as well as the FormBackingObject method which returns the SomeBean member for brevity.
The documentation / examples I have discovered make no mention of having to implement handleRequestInternal (which looks like it is inherited all the way from AbstractController), merely processFinish, processCancel, and validatePage. Spring appears to be invoking handleRequestInternal when a request for /wizard.do is received (wizard.do is mapped to this controller), as I receive the UnsupportedOperationException. I was able to gain partial functionality (the ability to move from page 0 to page 1 in the wizard) by implementing this:
Code:
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
if(isFormSubmission(request))
return new ModelAndView(this.getViewName(request, getS(),getTargetPage(request, this.getCurrentPage(request))));
else
return new ModelAndView(this.getViewName(request, getS(),0));
}
and specifying an _page=0 and _target1 parameter in my wizard0.jsp form, but this just does not seem right. Additionally, I have seen this error in my logs:
Code:
SEVERE: Servlet.service() for servlet spring threw exception
java.lang.IllegalStateException: Page attribute [com.example.WizardCreate.PAGE.WizardBean] neither found in session nor in request
at org.springframework.web.servlet.mvc.AbstractWizardFormController.getCurrentPage(AbstractWizardFormController.java:550)
at com.example.WizardCreate.handleRequestInternal(WizardCreate.java:36)
which makes it look like Spring/my wizard is not setting the appropriate page attribute in the session.
My environment is Mac OS X 10.5, Netbeans 6.5, and Apache Tomcat 6.0.18. Has anyone else encountered this issue before, or have any insight on how I might resolve it?