Announcement Announcement Module
Collapse
No announcement yet.
SWF Model Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SWF Model

    Hi,
    I would have one more question concerning the model in SWF. I have the flow- config- file above with one model "registrationModel". This model should be equipped with data in the first view-state and also in the second view- state -> e.g. in the first view-state (JSP) there is a form for firstname and surname and in the second JSP there is a form for the address.
    In my SWF- application now either the data of the first form or the data of the second form is set into the model but not all data.
    Does anyone have an idea how I can do this, that both, the data of the first form and the data of the second form is stored into the model "registrationModel" or how I can find information about that?
    Thanks a lot!,
    All the best,
    Generic1


    Code:
    <?xml version="1.0" encoding="UTF-8"?>
     
    <flow xmlns="http://www.springframework.org/schema/webflow"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/webflow
            http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
     
        <view-state id="register" view="account/registerForm"  model="registrationModel" redirect="true">
            <transition on="submitRegistration" to="accountAdded" />
            <transition on="cancelRegistration" to="cancelRegistration"/>
        </view-state>
     
            <view-state id="accountAdded" view="account/accountAdded" model="registrationModel" redirect="true">
                <transition on="submitRegistration" to="endRegistration" />
                <transition on="cancelRegistration" to="endRegistration"/>
            </view-state>
     
        <end-state id="endRegistration" view="externalRedirect:contextRelative:/home.do" />
    </flow>

  • #2
    Well you don't say in which webflow scope you stored the variable registrationModel, but if you put it into the flowContext you should have the behavior you wish for.

    Comment


    • #3
      Hello,

      thanks for the reply, currently I have declared the registrationModel- Bean in my servlet- config - file (myservlet-servlet.xml).
      How can I do this in order to put the registrationModel into the flowContext?
      Do I have to set an attribute or do I have to declare the registrationModel- Bean in another file or ...?
      Thanks a lot.
      All the best.
      Generic1

      Comment


      • #4
        Now I have tries this one but I still have the same problem. Do you have any idea, what I can do in order to set all data into the model registrationModel?
        Thanks a lot.
        Generic1

        HTML Code:
        <flow xmlns="http://www.springframework.org/schema/webflow"
        	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        	xsi:schemaLocation="http://www.springframework.org/schema/webflow
        		http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
        
                <var name="registrationModel" class="mycart.RegistrationModel" />
        
        	<view-state id="register" view="account/registerForm" >
        		<transition on="submitRegistration" to="accountAdded" bind="true"/>
        		<transition on="cancelRegistration" to="cancelRegistration" bind="true"/>
        	</view-state>
        
                <view-state id="accountAdded" view="account/accountAdded">
                    <transition on="submitRegistration" to="cancelRegistration" bind="true"/>
                    <transition on="cancelRegistration" to="cancelRegistration" bind="true"/>
                </view-state>
        
        	<end-state id="cancelRegistration" view="externalRedirect:contextRelative:/home.do" />
        </flow>

        Comment


        • #5
          now you forgot:

          model="registrationModel" in the view-state

          Comment


          • #6
            OK, thats an older version, the current flow XML file looks like this:


            HTML Code:
            <flow xmlns="http://www.springframework.org/schema/webflow"
            	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            	xsi:schemaLocation="http://www.springframework.org/schema/webflow
            		http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
            
                    <var name="registrationModel" class="mycart.RegistrationModel" />
            
            	<view-state id="register" view="account/registerForm" model="registrationModel">
            		<transition on="submitRegistration" to="accountAdded" bind="true"/>
            		<transition on="cancelRegistration" to="cancelRegistration" bind="true"/>
            	</view-state>
            
                    <view-state id="accountAdded" view="account/accountAdded" model="registrationModel">
                        <transition on="submitRegistration" to="cancelRegistration" bind="true"/>
                        <transition on="cancelRegistration" to="cancelRegistration" bind="true"/>
                    </view-state>
            
            	<end-state id="cancelRegistration" view="externalRedirect:contextRelative:/home.do" />
            </flow>
            do you have any idea what I am doing wrong.
            Thanks!!

            Comment


            • #7
              Well from what I know and from what I see your problem is not in the flow definition xml anymore.

              Comment


              • #8
                I habe a very simple Testapplication. I have uploaded this one.
                It would be great if you could take a look on it.
                Thanks a lot!!

                http://www.file-upload.net/download-...ation.zip.html

                Comment


                • #9
                  I think you didnt understand from the docs how webflow works. So I recommend you read them again and then try to look at some of the sample applications.

                  Well for now from the jsp, on the form tag, erase the action attribute. That is making you go to the spring-mvc controller instead of the webflow.

                  Comment


                  • #10
                    Hi,

                    thanks again for the reply, I have looked for an example, where a model is used for more than one JSP but I couldn't find one -> Actually this is my problem - I have no example where I can have a look how to do it.

                    Comment


                    • #11
                      Your problem is that you don't understand what is a model and you didn't read any documentation, so you don't even understand how webflow works. That will make everything harder.

                      Did you try to do what i told you and erase the action attribute from the form?

                      Comment


                      • #12
                        Your Web flow definition looks Okay.

                        Are you binding the model to the form on your jsp? See example below:
                        Code:
                        <form:form  method = "post" modelAttribute = "registerationModel">
                        </form:form>

                        Comment


                        • #13
                          I have erased the action- attribute and now it works fine, if I have <hidden- fields for all data in the last JSP (in the form in this JSP I have the action attribute and afterwards the Controller is invoked).

                          Is this a must to have hidden- fields in the last for befor invoking the Controller or do I still something wrong?

                          All the best,
                          Generic1

                          Comment

                          Working...
                          X