Results 1 to 5 of 5

Thread: Strange setup bean behaviour with validation

  1. #1
    Join Date
    Aug 2004
    Location
    Paderborn, Germany
    Posts
    24

    Default Strange setup bean behaviour with validation

    Hi,
    I've stumbeld across a strange behaviour of the new setup bean action element when it is used togehter with validation. Don't know if it's a bug or if I do something wrong(which might be more probable ) 8).

    When I define my workflows with the new setup bean action element and the form is redisplayed for correction because a validation error occured, no error messages are shown. When I replace the setup bean action with a "normal" action state for the setupForm method of my FormAction, error messages are shown correctly.

    Here is the code:
    The flow definition that doesn't work:
    Code:
    <webflow id="loginFlow" start-state="loginForm. view">
    	
    	<view-state id="loginForm.view" view="loginForm">
    		<setup bean="flow.login.LoginAction" method="setupForm"/>
    		<transition on="submit" to="launch.project.flow">		
                <action bean="flow.login.LoginAction" method="bindAndValidate"/>
             </transition>
    		 <transition on="error" to="loginForm.view"/>
    	</view-state>
    		
    	<end-state id="launch.project.flow" view="redirect&#58;/flowController?_flowId=projectFlow"/>
    
    </webflow>
    The working definition:
    Code:
    <webflow id="loginFlow" start-state="setupForm.action">
    
    	<action-state id="setupForm.action">
    		<action bean="flow.login.LoginAction" method="setupForm"/>
    		<transition on="success" to="loginForm.view"/>
    	</action-state>
    	
    	<view-state id="loginForm.view" view="loginForm">
    		<transition on="submit" to="launch.project.flow">		
                <action bean="flow.login.LoginAction" method="bindAndValidate"/>
             </transition>
    		 <transition on="error" to="loginForm.view"/>
    	</view-state>
    		
    	<end-state id="launch.project.flow" view="redirect&#58;/flowController?_flowId=projectFlow"/>
    
    </webflow>
    the JSP page:
    Code:
    <FORM method="POST" action="flowController" >			
    			<%-- needed to keep track of the flow-status of the client --%>
    			<INPUT type="hidden" name="_flowExecutionId" value="<c&#58;out value="$&#123;flowExecutionId&#125;"/>">
    				
    			<%-- Spring tags to bind the entered values automatically to bean attributes and to print error messages  --%>
    			
    			<TABLE border="0">
    
    					<tr>
    						<td>
    					<spring&#58;bind path="formBean.login">
    						<input type="text" name="<c&#58;out value="$&#123;status.expression&#125;" />" value="<c&#58;out value="$&#123;status.value&#125;" />"/>
    						<DIV style="color&#58;red">	
    							<c&#58;forEach var="error" items="$&#123;status.errorMessages&#125;"><li><c&#58;out value="$&#123;error&#125;" /></li></c&#58;forEach>
    						</DIV>
    					</spring&#58;bind>
    					</td>
    					</tr>
    					<tr>
    						<td>
    						<spring&#58;bind path="formBean.password">
    						<input type="password" name="<c&#58;out value="$&#123;status.expression&#125;" />" value="<c&#58;out value="$&#123;status.value&#125;" />"/>
    						<DIV style="color&#58;red">	
    							<c&#58;forEach var="error" items="$&#123;status.errorMessages&#125;"><li><c&#58;out value="$&#123;error&#125;" /></li></c&#58;forEach>
    						</DIV>
    					</spring&#58;bind>
    					</td>
    					</tr>
    				
    				<TR>
    					<TD colspan="2" align="right">
    						<%-- _eventId is used to choose the next transition --%>
    						<INPUT type="submit" value="submit" name="_eventId"></TD>
    				</TR>
    			</TABLE>
    						
    		</FORM>
    My Validator:
    Code:
    ...
    public void validate&#40;Object obj, Errors errors&#41; &#123;
            LoginFormBean loginData = &#40;LoginFormBean&#41;obj;
            validateLoginAndPassword&#40;loginData, errors&#41;;
        &#125;
        
        private void validateLoginAndPassword&#40;LoginFormBean loginData, Errors errors&#41; &#123;
            LogFactory.getLogger&#40;this&#41;.debug&#40;"Validating login data"&#41;;
            
            ValidationUtils.rejectIfEmptyOrWhitespace&#40;errors,"login",null,"Please specify your login name"&#41;;
            ValidationUtils.rejectIfEmptyOrWhitespace&#40;errors,"password",null,"Please specify your password"&#41;;
            
        &#125;
    ...
    Any ideas?

    Chris
    It\'s better to be an optimist who is sometimes wrong than a pessimist who is always right!

    90% of the PC problems are between the keyboard and the chair

  2. #2
    Join Date
    Aug 2004
    Location
    Paderborn, Germany
    Posts
    24

    Default

    Damn it, just stumbled across this line in the Preview 4 - Completed Changes change log:

    Fixed problem with 'form states': view states that use a setup action and a bindAndValidate when transitioning out of the state. The validation errors generated by the bindAndValidate were being overwritten by the setupForm action when the view state re-entered.
    think that's it, i will download the latest version from the CVS now and try again.[/quote]
    It\'s better to be an optimist who is sometimes wrong than a pessimist who is always right!

    90% of the PC problems are between the keyboard and the chair

  3. #3
    Join Date
    Sep 2004
    Location
    Leuven, Belgium
    Posts
    1,853

    Default

    Note that SWF has moved out of the spring sandbox and is now in its own repository (spring-projects/spring-webflow) at SourceForge (http://cvs.sourceforge.net/viewcvs.p...pring-webflow/).

    The migration is still in progress. In particular the Portlet related code has yet to find a new home.

    Anyway, to build it, you have to pull in ALL the sub-modules of "spring-projects". Once that is done, you can do "build dist" in the spring-webflow module to build a SWF jar that you can use with the existing webflow-support.jar.

    Erwin

  4. #4
    Join Date
    Aug 2004
    Location
    Paderborn, Germany
    Posts
    24

    Default

    Is there a complete PR4 jar in the CVS? I've checked out the whole spring-projects in Eclipse and then tried to run the build.xml file in the spring-webflow folder. The build fails with the following error message:

    common-targets.xml: 297: Unable to find typedef antlib:fr.jayasoft.ivy.ant:resolve

    If there is a quick fix for this or a description of how to build the project with Eclipse please post an answer. Otherwise I will wait for PR4 .

    Christian
    It\'s better to be an optimist who is sometimes wrong than a pessimist who is always right!

    90% of the PC problems are between the keyboard and the chair

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

    Default

    You're on the right track. The new build system using ivy for dependency management. To build successfully from ant, you need ivy-1.1.jar in your ant classpath.
    Keith Donald
    Core Spring Development Team

Similar Threads

  1. Order of Bean definitions matters?
    By cfuser in forum Container
    Replies: 2
    Last Post: Oct 21st, 2005, 10:29 AM
  2. Spring container fails with no exception
    By naor in forum Container
    Replies: 9
    Last Post: Oct 1st, 2005, 03:39 PM
  3. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  4. could not satisfy dependencies
    By springuser in forum Container
    Replies: 4
    Last Post: Apr 26th, 2005, 01:15 PM
  5. Replies: 1
    Last Post: Apr 25th, 2005, 07:37 PM

Posting Permissions

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