Results 1 to 4 of 4

Thread: swf 2.0.7 + a4j

  1. #1
    Join Date
    Jun 2009
    Posts
    8

    Default swf 2.0.7 + a4j

    I've integrated spring web flow with richfaces. My problem is that a4j request is not updating the page properly. The a4j request is hitting server but fails to update page until I click the browser refresh button.

    I've seen this question in more than one thread on this forum, but none have helped me.

    I'm using spring 2.5.6 + swf 2.0.7 + richfaces3.3.1.GA. All integration is currently working besides a4j.

    Any help is appreciated. Here is my code:

    web-mvc.config:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:util="http://www.springframework.org/schema/util"
           xsi:schemaLocation="
               http://www.springframework.org/schema/beans
               http://www.springframework.org/schema/beans/spring-beans-2.5.xsd>
               
               
               
        <!-- Maps request paths to flows in the flowRegistry; e.g. a path of /hotels/booking looks for a flow with id "hotels/booking" -->
    	<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
    		<property name="order" value="0" />
    		<property name="flowRegistry" ref="flowRegistry" />
    	</bean>
    
    	<!-- Maps request paths to @Controller classes; e.g. a path of /hotels looks for a controller named HotelsController -->
    	<bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping">
    		<property name="order" value="1" />
    		<property name="defaultHandler">
    			<!-- If no @Controller match, map path to a view to render; e.g. the "/intro" path would map to the view named "intro" -->	
    			<bean class="org.springframework.web.servlet.mvc.UrlFilenameViewController" />
    		</property>
    	</bean>
    	
    
        <!-- Maps logical view names to Facelet templates in /WEB-INF (e.g. 'search' to '/WEB-INF/search.xhtml' -->
        <bean id="faceletsViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
            <property name="viewClass" value="org.springframework.faces.mvc.JsfView"/>
            <property name="prefix" value="/WEB-INF/" />
            <property name="suffix" value=".xhtml" />
        </bean>
    
    	
        
    
        <!-- Dispatches requests mapped to org.springframework.web.servlet.mvc.Controller implementations -->
        <bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" />
        
    
        <!-- Dispatches requests mapped to flows to FlowHandler implementations -->
        <bean class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter">
            <property name="flowExecutor" ref="flowExecutor" />
            <!-- RichFaces integration -->
    		<property name="ajaxHandler">
    			<bean class="org.springframework.faces.richfaces.RichFacesAjaxHandler"/>
    		</property>
        </bean>

    web-flow.config:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:webflow="http://www.springframework.org/schema/webflow-config"
           xmlns:faces="http://www.springframework.org/schema/faces"
           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.0.xsd">
    
        <!-- Executes flows: the central entry point into the Spring Web Flow system -->
        <webflow:flow-executor id="flowExecutor">
    	<webflow:flow-execution-listeners>
    			<webflow:listener ref="securityFlowExecutionListener" />				
    		</webflow:flow-execution-listeners>
        </webflow:flow-executor>
        
        <!-- The registry of executable flow definitions -->
        <webflow:flow-registry id="flowRegistry" flow-builder-services="facesFlowBuilderServices" base-path="/WEB-INF/flows">
            <webflow:flow-location-pattern value="/**/*-flow.xml" />
        </webflow:flow-registry>
        
        <!-- Configures the Spring Web Flow JSF integration -->
        <faces:flow-builder-services id="facesFlowBuilderServices" development="true" />
    
    
    
    <!-- Installs a listener to apply Spring Security authorities -->
    	<bean id="securityFlowExecutionListener" class="org.springframework.webflow.security.SecurityFlowExecutionListener" />
    
    </beans>

    web.xml: (relevant code)
    Code:
        
        
        <!-- Use JSF view templates saved as *.xhtml, for use with Facelets -->
        <context-param>
            <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
            <param-value>.xhtml</param-value>
        </context-param>
        
        <!-- Enables special Facelets debug output during development -->
        <context-param>
            <param-name>facelets.DEVELOPMENT</param-name>
            <param-value>true</param-value>
        </context-param>
        
        <!-- Causes Facelets to refresh templates during development -->
        <context-param>
            <param-name>facelets.REFRESH_PERIOD</param-name>
            <param-value>1</param-value>
        </context-param>
        
        
      
       <!-- Start RichFaces Configuration -->
    	
    	<!-- Defining and mapping the RichFaces filter -->
    	<filter> 
       	<display-name>RichFaces Filter</display-name> 
       	<filter-name>richfaces</filter-name> 
       	<filter-class>org.ajax4jsf.Filter</filter-class> 
    	</filter> 
    
    	
    	<filter-mapping> 
       	<filter-name>richfaces</filter-name> 
       	<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
       	<dispatcher>REQUEST</dispatcher>
       	<dispatcher>FORWARD</dispatcher>
       	<dispatcher>INCLUDE</dispatcher>
    	</filter-mapping>
        
       <!-- End RichFaces Configuration -->
        
        
        
        
        <!-- The front controller of this Spring Web application, responsible for handling all application requests -->
        <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></param-value>
            </init-param>
            <load-on-startup>2</load-on-startup>
        </servlet>
    
        <!-- Map all /spring requests to the Dispatcher Servlet for handling -->
        <servlet-mapping>
            <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
            <url-pattern>/vault/*</url-pattern>
        </servlet-mapping>
    
        <!-- Just here so the JSF implementation can initialize, *not* used at runtime -->
        <servlet>
            <servlet-name>Faces Servlet</servlet-name>
            <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
            <load-on-startup>1</load-on-startup>
        </servlet>
        
        <!-- Just here so the JSF implementation can initialize -->
        <servlet-mapping>
            <servlet-name>Faces Servlet</servlet-name>
            <url-pattern>*.faces</url-pattern>
        </servlet-mapping>

    faces-config.xml:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <faces-config>
        <application>
            <!-- Enables Facelets -->
            <view-handler>com.sun.facelets.FaceletViewHandler</view-handler> 
            <variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver> 
        </application>
    </faces-config>

    flow.xml:
    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">
    	
    	<view-state id="enterSearchCriteria">
    		<transition on="getGreeting">
    			<evaluate expression="'Bob'" result="viewScope.outputName" />
    			<render fragments="greetingFragment" />
    		</transition>
    	</view-state>
    	
    	
    </flow>

    xhtml:
    Code:
    <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <ui:composition xmlns="http://www.w3.org/1999/xhtml"
    	xmlns:ui="http://java.sun.com/jsf/facelets"
    	xmlns:h="http://java.sun.com/jsf/html"
    	xmlns:f="http://java.sun.com/jsf/core"
    	xmlns:sf="http://www.springframework.org/tags/faces"
    	xmlns:a4j="http://richfaces.org/a4j"
            xmlns:rich="http://richfaces.org/rich"
    	template="/WEB-INF/layouts/standard.xhtml">
    
    
    <ui:define name="content">
    	<a4j:outputPanel id="greetingFragment">
    		
    		<h:form id="mainForm">
    		
            	<h:outputText value="Your name: " />
               	<h:inputText id="myname">
              		<f:validateLength minimum="1" maximum="30" />
    		</h:inputText>
    
    		
    		<a4j:commandButton id="cancel" value="Ajax" reRender="#{flowRenderFragments}" action="getGreeting"/>
    		
                    <h:outputText value="Hello, "  />
                    <h:outputText value="#{outputName}" />
         		
    		</h:form>
    	
    	</a4j:outputPanel>
    
    </ui:define>
    </ui:composition>

  2. #2
    Join Date
    Jun 2009
    Posts
    8

    Default

    I got my example working by implementing a jsf managed bean rather than just evaluating a string literal ('Bob') in my flow definition file. Still don't understand why original a4j example only works after refreshing browser.

  3. #3
    Join Date
    Nov 2008
    Posts
    742

    Default

    Something about that evaluation...

    Can you try using the set tag instead of the evaluate tag?

    Code:
    <set name="viewScope.outputName" value="'Bob'" />
    Also, if you want to ensure something renders no matter what problems might be encountered by evaluate elements, try moving the render fragments tag to the top.

  4. #4
    Join Date
    Aug 2009
    Location
    DC Metro
    Posts
    2

    Default

    I'm having same problem and struggling for last few days. Its really frustrating...Can you please post your configuration where you put the manged bean config??

Posting Permissions

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