Announcement Announcement Module
Collapse
No announcement yet.
form backing object not getting updated Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • form backing object not getting updated

    Hi,

    I have a set of records in a form:

    Code:
    <form:form modelAttribute="items" 
    	action="${flowExecutionKey}" id="form">
    	<c:forEach items="${items}" var="record">
    		<INPUT type="hidden" name="record<c:out value="${record.id}"/>"
    			id="record<c:out value="${record.id}"/>" 
    		value="${record.description},${record.category.id},${record.set}" />
    	</c:forEach>
    </form:form>
    ....
    <form action="${flowExecutionUrl}&_eventId=next" method="post"><input
    	type="submit" value="Next"></form>
    The value is getting updated pragmatically by JavaScript.

    The view-state is defined at:

    Code:
    	<view-state id="enterItems" redirect="false" popup="false"
    		view="/WEB-INF/views/items.jsp" 
    		model="flowScope.items">
    		<transition on="next" to="enterNext" />
    		<transition on="back" to="enterPrevious" />
    		<on-exit>
    			<evaluate expression="itemsBackingObject.setItems(flowScope.items)" />
    		</on-exit>
    	</view-state>

    However, the backing object is not getting updated when I hit the "nex" button. I basically get the items back that I enter the state with.
    Is above code supposed to work or do I need something else to bind my model?
    Thanks for help and sorry if the question might be trivial. (It's what I understand with the new model binding in Spring webflow 2.0.).

  • #2
    Use items instead of flowScope.items in your model expression.

    Comment


    • #3
      I did change it to:
      Code:
      	<view-state id="enterItems" redirect="false" popup="false"
      		view="/WEB-INF/views/items.jsp" 
      		model="items">
      		<transition on="next" to="enterNext" />
      		<transition on="back" to="enterPrevious" />
      		<on-exit>
      			<evaluate expression="itemsBackingObject.setItems(items)" />
      		</on-exit>
      	</view-state>
      But no change.

      I read through previous posts and noticed that my ${record.id} is of type Integer. Somebody mentioned that there were problems in the past. Could that be the case?
      I also wonder if I need a CustomCollectionClass since my model is not trivial and the hidden input field manipulates various record fields of my backing object.

      (In a previous state in my program I bind a HibernateDAO object directly as a model with pretty much the same syntax and that works fine.)

      Comment


      • #4
        I tried ${record.id} with type String. That didn't help either.

        Comment

        Working...
        X