Announcement Announcement Module
Collapse
No announcement yet.
AbstractWizardFormController and abstract HandleRequestInternal Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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?
    Last edited by PAmes; Dec 19th, 2008, 01:05 AM. Reason: Add details.

  • #2
    Hi,

    Can you tell which version of spring are you using,

    you do not need to override the handleRequestInternal method,

    this method is already overridden at the AbstractFormController,

    you need to only override the processFinish

    Comment


    • #3
      Originally posted by sami25 View Post
      Hi,

      Can you tell which version of spring are you using,

      you do not need to override the handleRequestInternal method,

      this method is already overridden at the AbstractFormController,

      you need to only override the processFinish
      Thank you for your response. I am using Spring 2.5.6, and you are absolutely correct that AbstractFormController provides an implementation of handleRequestInternal. Oddly enough, Netbeans does not seem to acknowledge that fact. If I change the body of my WizardCreate handleRequestInternal to "return super.handleRequestInternal(request, response);" it complains that "abstract method handleRequestInternal(javax.servlet.http.HttpServl etRequest, javax.servlet.http.HttpServletResponse) in org.springframework.web.servlet.mvc.AbstractContro ller cannot be accessed directly" and will not compile.

      Based on your suggestion, though, I downloaded the latest version of Spring (I was using files from 'spring-framework-2.5-with-docs.zip' and am now using 'spring-framework-2.5.6-with-dependencies.zip') and everything seems to work now.

      Thank you for your assistance!

      Comment

      Working...
      X