Announcement Announcement Module
Collapse
No announcement yet.
Cities and States dropdown lists and Spring Validation Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Cities and States dropdown lists and Spring Validation

    I have a page within a Web Flow that gathers location information. In this page is a STATES dropdown list (containing all the states in the US). When the user selects a state, the loadCities event is triggered, the cities are populated, and the page is returned with the list of cities.

    The problem I now have occurred after I added validation to the form. Now that validation is in place, the user cannot select a STATE from the list and get the list of cities without first completing all the other required fields on the page.

    The list of cities is never populated because the rest of the form is empty.

    What I would like to do is use the loadCities action to load the cityList into the page even if all of the required fields have not been filled in.

    Can anyone direct me on how to do this?

    Here is the xml for my flow:
    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">
    
    	<var name="register" class="com.website.flow.model.registration.Register" />
    	<var name="registerEntity" class="com.website.flow.model.registration.RegisterEntity" />
    	<var name="registerUser" class="com.website.flow.model.registration.RegisterUser" />
    	
    	<on-start>
    		<evaluate expression="registrationModelAction.init" />
    	</on-start>
    	
    	<view-state id="start" view="../jsp/registration/registerStart.jsp" model="register">
    		<transition on="save" to="entity" />
    	</view-state>
     	
     	<view-state id="entity" view="../jsp/registration/registerEntity.jsp" model="registerEntity">
     		<on-entry>
     			<evaluate expression="registrationModelAction.loadStates" />
     		</on-entry>	
     		<transition on="loadCities" to="loadCitiesAction" />
     		<transition on="registerEntity" to="user" />
     	</view-state>
     	
     	<view-state id="user" view="../jsp/registration/registerUser.jsp" model="registerUser">
     		
     	</view-state>
     	
     	<action-state id="loadCitiesAction">
     		<evaluate expression="registrationModelAction.loadCities" />
     		<transition on="done" to="entity" />
     	</action-state>
     	
        <end-state id="end" />
    
    </flow>

  • #2
    Duh! It's so easy a caveman could do it!

    I just needed to add the "validate" property to the transition element of my view and set it equal to "false" this suppresses validation for this specific action and gives me the desired outcome.

    EDIT: here is the updated view element in my flow description:
    Code:
    <view-state id="entity" view="../jsp/registration/registerEntity.jsp" model="registerEntity">
     		<on-entry>
     			<evaluate expression="registrationModelAction.loadStates" />
     		</on-entry>	
     		<transition on="loadCities" to="loadCitiesAction" validate="false" />
     		<transition on="registerEntity" to="user" />
     	</view-state>

    Comment

    Working...
    X