Results 1 to 9 of 9

Thread: does formcontroller support multiple successview?

  1. #1
    Join Date
    May 2005
    Posts
    4

    Default does formcontroller support multiple successview?

    I'm currently evaluating spring and has this question: Does spring web tier's formcontroller support map to multiple successview? e.g. a screen may route to different view base on some business logic in the controller, then how spring do that. Also how to define the mapping in xml?

    Thanks in advance for any reply.

    Rgds,
    Arthur

  2. #2
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    This is just simple IoC - I think the setSuccessView/getSuccessView methods are just added for convenience - you can add whatever views you want. Take a look at the SimpleFormController source and it should become clear.

  3. #3
    Join Date
    May 2005
    Posts
    4

    Default

    I get your point and you are correct. By looking into SimpleFormController, if you not return the ModelAndView, it will use the default: SuccessView. If it is not defined, exception will throw. However, I personally not prefer to define such mapping using private fields in the formcontroller as it require lot of typing (even eclipse help a lot in creating the getter/setter). It would be nice for me to just return the result action and the framework will redirect on behalf of me. (That's what our framework current does) However, spring has a nice thing which is the spring:bind in handling error of an input form. It is much clean.

  4. #4
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    I personally not prefer to define such mapping using private fields in the formcontroller as it require lot of typing
    You could ue a Map.

  5. #5
    Join Date
    May 2005
    Posts
    4

    Default

    Your suggestion is much better as only one getter/setter require to define for each form on the action mapping. With defining a java editor template for this in eclipse will nearly solve the "typing issue". However, in terms of framework design, I still think it is the job of the framework to perform this and I just need to return the result action. sorry for this insist

  6. #6
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    sorry for this insist
    No dramas

    I still think it is the job of the framework to perform this(map to multiple successview?)
    SimpleFormController is only a convenience class. If you think needs another, you can submit the one you are going to develop to JIRA for inclusion in future releases.

  7. #7
    Join Date
    May 2005
    Location
    California, US
    Posts
    735

    Default

    The lines of interest are the adminView and waitlistView:
    Code:
        <bean id="adminSignInCtlr" class="ctlr.AdminSignInCtlr">
            <property name="commandClass" value="view.AdminSignInFrmData" />
            <property name="validator" ref="adminSignInValidate" />
            <property name="formView" value="adminSignInView" />
            <property name="adminView" value="fdebugView" />
            <property name="waitlistView" value="waitlistView" />
            <property name="sessionForm" value="false" />
            <property name="bindOnNewForm" value="true" />
            <property name="facilityDao" ref="facilityDao" />
            <property name="wleDao" ref="wleDao" />
        </bean>
    This is a snippet of code from my SimpleFormController. Notice that the views it's returning correspond to the 2 properties I set up in the -servlet.xml file. So you can add your own views and have as many as you want your controller to branch to.
    Code:
        private String      adminView;
        private String      waitlistView;
    
    ...
        protected ModelAndView
        onSubmit&#40;Object cmd&#41; &#123;
    ...
            if &#40;view.equals&#40;"admin"&#41;&#41;
                return&#40;new ModelAndView&#40;adminView, "model", model&#41;&#41;;
    
            if &#40;view.equals&#40;"waitlist"&#41;&#41;
                return&#40;new ModelAndView&#40;waitlistView, "model", model&#41;&#41;;
    &#125;
    ...
        public void
        setAdminView&#40;String adminView&#41; &#123;
            this.adminView = adminView;
        &#125;
    
        public void
        setWaitlistView&#40;String waitlistView&#41; &#123;
            this.waitlistView = waitlistView;
        &#125;
    In the above java code "view" of view.equals( is the string data from a form field, it just happens to have the name of "view". I'm converting a legacy php app.
    Here's a partial listing of my source directory:
    Code:
    ./war/WEB-INF/jsp&#58;
    CVS/                  fdebugView.jsp        waitlistView2.jsp
    adminSignInView.jsp   include.jsp
    debugView.jsp         waitlistView.jsp

  8. #8
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    Quote Originally Posted by lumpynose
    private String adminView;
    Quote Originally Posted by ArthurTam
    I personally not prefer to define such mapping using private fields in the formcontroller
    I don't think this is what ArthurTam is after.

  9. #9
    Join Date
    May 2005
    Posts
    4

    Default

    you can submit the one you are going to develop to JIRA for inclusion in future releases.
    I will try this and ask for your help (or post a question in this forum) if there is any problem in submitting things to JIRA as I'm new to this communities.


    I don't think this is what ArthurTam is after.
    katentim, you are right. lumpynose's suggestion was what I'm not prefer.

Similar Threads

  1. JUnit tests - Support multiple databases
    By ejhernand3z in forum Data
    Replies: 5
    Last Post: Oct 22nd, 2008, 02:41 PM
  2. Replies: 3
    Last Post: Aug 2nd, 2005, 03:43 AM
  3. OJB multiple database support
    By lcheng in forum Data
    Replies: 0
    Last Post: Nov 19th, 2004, 06:44 AM
  4. Spring FormController lacks POST -> REDIRECT support.
    By DaVinci79 in forum Architecture
    Replies: 2
    Last Post: Oct 21st, 2004, 03:24 AM
  5. Replies: 2
    Last Post: Sep 14th, 2004, 09:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •