Announcement Announcement Module
Collapse
No announcement yet.
spring web flow 2: multiple forms inside a view-state Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring web flow 2: multiple forms inside a view-state

    Hi,

    I have a complex screen mapped to a single view-state so that using ajax requests I can reload only parts of the screen. The screen has multiple forms used by Spring.remoting.submitForm() calls in order to execute some transitions INSIDE the same state-view and resulting in reloading only some parts of the screen. How can I bind different beans for each form inside my page. It seems for me that webflow2 allows only one model to be bound to the whole view-state by specifying it as attribute of the view-state tag:

    Code:
    <view-state id="searchScreen" view="swe_cparty_search" model="searchCriteria">  
    ...
    </view-state>
    Ideally, I would like a model to be specified for transition tag for binding purposes like so:

    Code:
    <transition on="spnSelected" bind="true" model="modelForFormX">
    </transition>
    But there isn't any attribute for doing it inside transition tag.

    So how can i speficy a binding model for a transition? I believe that for complex screens that want to reload only parts of them having a way to bind a bean to a transition and not to the whole view-state is essential.

    Thank you.

  • #2
    Hi,

    I am facing the same problem in binding two forms in a view-state..
    Did you able to resolve the issue?
    if yes, can you share the same?

    Thanks,
    Subhrajit

    Comment


    • #3
      Yes, I did:
      I created an aggregated model that is used the whole screen as follows:
      Java:
      Code:
      @Component("sweCpartyAggregateDto")
      public class SweCpartyAggregateDto {
          private Form1Dto form1Dto;
          private Form2Dto form2Dto;
          // getters, setters
      }
      The flow file:
      Code:
      <view-state id="editSweCparty" view="swe_cparty" model="sweCpartyAggregateDto"> 
      ...
      </view-state>
      First form in JSP:
      Code:
      <form:form modelAttribute="sweCpartyAggregateDto.form1Dto">
      ...
      </form:form>

      Comment


      • #4
        Hi vbrasov,
        I've got the same problem as you and did you described.
        But it does not work for me.
        My problem is:
        I have a formular "mandatorydata-change.jsp" where you have to be given out the contact details (name, first name, ...) the address data of the user. The address information will have his own table, which is different to the table other attributes.
        Now I want to save via Spring WebFlow 2, the address data of the user in user address table.
        I have defined the address user flow as a subflow (child-flow) in mandatorydata-change (parent-flow).
        Here are the code:
        In JSP:
        Code:
        ...
        <form:form method="post" modelAttribute="userDto.myAccount"> 
        ...
        <form:form method="post" modelAttribute="userDto.useraddress">
        ...
        </form:form>
        ...
        </form:form>
        In Parent-flow:
        Code:
        ...
        <on-start>
        		<evaluate expression="userService.getUserIdByUsername(currentUser.name)" result="flowScope.userId" />
        		<evaluate expression="userService.getUserById(flowScope.userId)" result="myAccount" />
        	</on-start>
        ...
        <view-state id="Mymmvmandatorydatachange" model="userDto">
        		<transition on="saveUserAddressData" to="MymmvUserAddress" />
        		<transition on="saveData" to="MymmvMandatoryDataChange" />
        	</view-state>
        ...
        <subflow-state id="MymmvUserAddress" subflow="myMMVuseraddress">   
        		<input name="useraddress" value="useraddress"/>
                <transition on="UseraddressEnd" to="Mymmvmandatorydatachange"/>
         	</subflow-state>
        ...
        In child-flow:
        Code:
        ...
        <var name="useraddress" class="mmv.pojos.Useraddress" /> 
        			
        	<action-state id="UseraddressSave">
        		<evaluate expression="userService.persistUseraddress(useraddress)" />
        		<transition on="success" to="UseraddressEnd">
        			<set name="flashScope.saveDataSuccess" value="true"/>
        		</transition>
        		<transition on="error" to="UseraddressEnd" />
        	</action-state>
        	
        	<end-state id="UseraddressEnd" commit="true" view="MymmvMandatoryData" />
        ...
        The aggregated model:
        Code:
        @Component("userDto")
        public class Userdto {
        
        	private User myAccount;
        	private Useraddress useraddress;
                // Getter and Setter
        }
        At launch "mandatorydata-change.jsp" I get the following error message:
        Code:
        ...
        org.springframework.binding.expression.EvaluationException: An OgnlException occurred getting the value for expression 'myAccount.username' on context [class mmv.dto.Userdto]
        ...
        ognl.OgnlException: source is null for getProperty(null, "username")
        ...
        Seeking a solution for three weeks, but in vain.
        can you please help me here?
        Thank you for your help.
        Last edited by Lukem; Jan 31st, 2011, 08:33 AM.

        Comment


        • #5
          Hello people,

          How do you submit these separate forms?
          Should the forms be nested?

          Comment

          Working...
          X