Results 1 to 7 of 7

Thread: Form not update when stay in the same view-state

  1. #1

    Question Form not update when stay in the same view-state

    Hi all,

    I have a bean named "cmd" with a field "name".
    Code:
     public class MyCommand
       {
          private String name;
    
          public String getName()
          {
             return name;
          }
    
          public void setName( final String name )
          {
             this.name = name;
          }
       }
    when start the name is 'oldname'.


    My flow is :
    Code:
     <view-state id="state1" model="cmd" view="views/cmd">
          <transition on="setNameEvent" to="state1">
             <evaluate expression="cmd.setName('newname')"/>
          </transition>
       </view-state>
    The form input text is never update with the value 'newname' but the old one 'oldname'

    I ve only this case when a transition leave enter in the same View-State with tags <form:input

    It makes me crazy.
    --

    Julien
    Last edited by jujuz; Mar 13th, 2009 at 04:38 AM.

  2. #2

    Default

    I ve found something interesting.

    Code:
     <view-state id="state1" model="cmd" view="views/cmd">
          <transition on="setNameEvent" to="confirm">
             <evaluate expression="cmd.setName('newname')"/>
          </transition>
       </view-state>
    
     <view-state id="confirm"  view="views/ok" >
          <transition on="confirmEvent" to="state1"/>
       </view-state>
    In this case it works. The bindingstatus is update.

    So how can I obtain the same result without go through a fake view?

  3. #3

    Cool

    Another thing interesting.

    when I remove the model in the view-state definition like this :
    Code:
     
    <view-state id="state1" view="views/cmd">
         <transition on="setNameEvent" to="confirm">
           <evaluate expression="cmd.setName('newname')"/>
        </transition>
    </view-state>

    it works, but I loose ALL custom binder.

    So What I misunderstand?

  4. #4

    Default Next step

    In the class org.springframework.webflow.mvc.view.BindingModel see this method

    Code:
    	public Object getFieldValue(String field) {
    		if (mappingResults != null) {
    			List results = mappingResults.getResults(new FieldErrorResult(field));
    			if (!results.isEmpty()) {
    				MappingResult fieldError = (MappingResult) results.get(0);
    				return fieldError.getOriginalValue();
    			}
    		}
    		return getFormattedValue(parseFieldExpression(field));
    	}
    I understand now whats happen. When I update the field because the mappingReszkts is not null it takes the original value, not the new value because it does not know that the real model value have changed.

    So how can I refresh this mappingResults?

  5. #5
    Join Date
    Aug 2004
    Location
    Melbourne, FL
    Posts
    2,794

    Default

    Upgrade to 2.0.6 when its out.

    Keith
    Keith Donald
    Core Spring Development Team

  6. #6

    Default

    Awsome !!
    thanks Keith

  7. #7
    Join Date
    Sep 2009
    Posts
    17

    Default no update of input fields after ajax render

    Hi Guys, I do have a very similar problem.

    My flow definition is
    Code:
    	<var name="searchForm" class="org.starthello.web.data.forms.SearchForm" />
    	
    	<view-state id="searchMeeting" view="searchCriteria.xhtml" model="searchForm">
    		<on-render>
    			<evaluate expression="mapService.updateCoordinatesByAdress(searchForm)"/>
    		</on-render>
    		<transition on="search" to="browseMeetings" >
    		</transition>
    		<transition on="searchCoordinates" >
    			<render fragments="searchForm:mapFragment"></render>
    		</transition>
    	</view-state>
    now in my xhtml i do hava an area definded with ui:mapFragment, which contains a google map, an adress field and two inputText fields that should display the coordinates that were calculated and stored in the form as seen in the flow above.
    here the relevant code
    Code:
    			<ui:fragment id="mapFragment">
    					<m:map width="500px" height="350px" latitude="#{searchForm.latitude}" longitude="#{searchForm.longitude}" id="map" renderOnWindowLoad="false" >
    						<m:mapControl name="GLargeMapControl" position="G_ANCHOR_BOTTOM_RIGHT"/>
    						<m:mapControl name="GMapTypeControl"/>  
    				        <m:marker latitude="#{searchForm.latitude}" longitude="#{searchForm.longitude}" draggable="true" >
    				        	<m:eventListener eventName="dragend" jsFunction="showStreet"/>
    				        </m:marker>
    
    					</m:map>
    						<h:inputText id="address" required="false"  value="#{searchForm.address}"/>
    					<sf:commandButton id="searchCoordinatesButton" action="searchCoordinates" processIds="searchForm" value="Auf Karte"/>
    						<h:inputText id="longitude" required="false"  value="#{searchForm.longitude}" rendered="true"/>
    						#{searchForm.longitude}
    						<h:inputText id="latitude" required="false"  value="#{searchForm.latitude}" rendered="true"/>
    						#{searchForm.latitude}
    now when i execute the transition, it mostly works fine, the map is rerendered. but the input fields containing the latitude/longitude are not updated. if i completely refresh the page (by F5), they're updated correctly.

    I am using webflow 2.0.7

    can anyone help me on this?

    TIA, simon

Posting Permissions

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