Announcement Announcement Module
Collapse
No announcement yet.
error in faces tag validations causes empty flowBean Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • error in faces tag validations causes empty flowBean

    Hi, all.

    I'm using spring webflow 2.3.0. with Mojarra 2.0.9

    When I try to use the JSF validation, for example with the attribute required="true" of an inputText control, the validation error is processed, but the flow context bean is not populated, an the rendered view has lost the values for its fields.

    this is my web.xml file:

    Code:
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd"
    	version="2.5">
    	<display-name>grabavoz.com</display-name>
    
    	<context-param>
    		<param-name>contextConfigLocation</param-name>
    		<param-value>classpath*:**/*Context.xml</param-value>
    	</context-param>
    	<context-param>
    		<description>
    			Comma-delimited list of context-relative resource paths
    			under which the JSF implementation
    			will look for application
    			configuration resources, before loading a configuration resource
    			named /WEB-INF/facesconfig.xml (if such a resource exists).
    		</description>
    		<param-name>javax.faces.CONFIG_FILES</param-name>
    		<param-value>/WEB-INF/faces-config.xml</param-value>
    	</context-param>
    	<context-param>
    		<description>
    			The default suffix for extension-mapped resources that
    			contain JSF components.Default is '.jsp'.
    		</description>
    		<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    		<param-value>.xhtml</param-value>
    	</context-param>
    	<context-param>
    		<description>
    			Monitors Faces JSP files for modifications and
    			synchronizes a running server with
    			the changes without restarting the
    			server. If this parameter is set to false or
    			removed from the
    			deployment descriptor, any changes made to Faces JSP files may
    			not be
    			seen by the server until it is restarted. This parameter is usually
    			set
    			to true while the Faces JSP files are being developed and debugged
    			in order to
    			improve the performance of the development environment.
    		</description>
    		<param-name>com.ibm.ws.jsf.JSP_UPDATE_CHECK</param-name>
    		<param-value>true</param-value>
    	</context-param>
    	<context-param>
    		<description>
    			Load JSF runtime when the application server starts up.
    			If this parameter is set to false or removed,
    			JSF runtime will be
    			loaded and initialized when the first JSF request is processed.
    			This
    			may disable custom JSF extensions, such as factories defined in the
    			project.
    		</description>
    		<param-name>com.ibm.ws.jsf.LOAD_FACES_CONFIG_AT_STARTUP</param-name>
    		<param-value>false</param-value>
    	</context-param>
    
    
    	<listener>
    		<display-name>ContextLoaderListener</display-name>
    		<listener-class>org.springframework.web.context.ContextLoaderListener
    		</listener-class>
    	</listener>
    
    	
    	<servlet>
    		<servlet-name>Faces Servlet</servlet-name>
    		<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    		<load-on-startup>1</load-on-startup>
    	</servlet>
    	<servlet-mapping>
    		<servlet-name>Faces Servlet</servlet-name>
    		<url-pattern>/faces/*</url-pattern>
    	</servlet-mapping>
    	
    
    	<servlet>
    		<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
    		<servlet-class>org.springframework.web.servlet.DispatcherServlet
    		</servlet-class>
    		<init-param>
    			<param-name>contextConfigLocation</param-name>
    			<param-value>/WEB-INF/swf2/ctx-config.xml
    				/WEB-INF/swf2/ctx-web-flow.xml</param-value>
    		</init-param>
    		<load-on-startup>1</load-on-startup>
    	</servlet>
    	<servlet-mapping>
    		<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
    		<url-pattern>/flows/*</url-pattern>
    	</servlet-mapping>
    </web-app>
    this is my faces-config.xml

    Code:
    <faces-config xmlns="http://java.sun.com/xml/ns/javaee"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
            version="2.0">
    
    </faces-config>
    spring ctx-web-flow.xml

    Code:
    <beans xmlns="http://www.springframework.org/schema/beans"
    		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    		xmlns:faces="http://www.springframework.org/schema/faces"
    		xmlns:webflow="http://www.springframework.org/schema/webflow-config"
    		xsi:schemaLocation="
    			http://www.springframework.org/schema/beans
    			http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    			http://www.springframework.org/schema/webflow-config
    			http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd
    			http://www.springframework.org/schema/faces
    			http://www.springframework.org/schema/faces/spring-faces-2.2.xsd">
    
    	  <!-- Launches new flow executions and resumes existing executions. -->
    		<webflow:flow-executor id="flowExecutor" flow-registry="flowRegistry">
    			<webflow:flow-execution-attributes>	
    				<webflow:always-redirect-on-pause value="false"/>						
    			</webflow:flow-execution-attributes>	
    			<webflow:flow-execution-listeners>
                	<webflow:listener ref="facesContextListener"/>
                	<webflow:listener ref="hibernateFlowExecutionListener" />
            	</webflow:flow-execution-listeners>								
    		</webflow:flow-executor>
    		
    		<bean id="hibernateFlowExecutionListener"  class="org.springframework.webflow.persistence.HibernateFlowExecutionListener">
        		<constructor-arg ref="sessionFactory" />
        		<constructor-arg ref="transacctionManager" />
    		</bean>
    		
            <!-- Creates the registry of flow definitions for this application -->
    		<webflow:flow-registry id="flowRegistry" flow-builder-services="facesFlowBuilderServices" base-path="/WEB-INF/flows">
        		<webflow:flow-location-pattern value="/**/*-flow.xml" />
    		</webflow:flow-registry>
    		<!-- <webflow:flow-execution-repository max-executions="5" max-execution-snapshots="30" /> -->
        
        	<!-- Configures the Spring Web Flow JSF integration -->
        	<faces:flow-builder-services id="facesFlowBuilderServices"  expression-parser="expressionParser" />
        	
        	<!-- A listener maintain one FacesContext instance per Web Flow request. -->
        	<bean id="facesContextListener" class="org.springframework.faces.webflow.FlowFacesContextLifecycleListener" />
        
        	<bean id="expressionParser" class="org.springframework.webflow.expression.el.WebFlowELExpressionParser">
    		    <constructor-arg>
    		        <!-- <bean class="org.apache.el.ExpressionFactoryImpl" />  -->
    		        <bean class="com.sun.el.ExpressionFactoryImpl" />
    		    </constructor-arg>
    		</bean> 
        
        	<bean  class="org.springframework.faces.webflow.JsfFlowHandlerAdapter">
    	        <property name="flowExecutor" ref="flowExecutor" />
    	    </bean>
    	    
    			
    		<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
    		    <property name="flowRegistry" ref="flowRegistry"/>
    		    <property name="order" value="1"/>
    		</bean>
    		
    		<faces:resources order="0" />
       		
    </beans>
    the bean:

    Code:
    public class FormCliente implements Serializable {
    	
    	private String email;
    	private String password;
    }
    and the xhtml:

    Code:
    	<h:form id="cliente" >  
            
    			            <h:outputLabel for="email" value="Correo Electrónico: *" />  
    			            <h:inputText id="email" value="#{cliente.email}" required="true" />
    			           
    			              
    			            <h:outputLabel for="password" value="Contraseña: *" />  
    			            <h:inputText id="password" value="#{cliente.password}" label="Contraseña"/>  
    
    			             <h:messages />  
                                        
                                        <h:commandButton action="ejecutar" value="Aceptar" />
    	</h:form>
    and the flow definition:

    Code:
    <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"
    	  start-state="altaClienteForm">
    	  
    	<persistence-context />
    
    	<on-start>
    		<evaluate expression="altasFlowBackingBean.createFormCliente()"  result="flowScope.cliente"/>
    	</on-start>
    	
    	<view-state id="altaClienteForm" model="cliente">
    		<transition on="ejecutar" to="action.vf.alta-cliente"/>
    		<transition on="volver" to="fin"/>
    	</view-state>
    
    ....
Working...
X