Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: XT Ajax Framework and Web Flow

  1. #1

    Default XT Ajax Framework and Web Flow

    I am trying to incorporate the XT Ajax Framework into one of my current flows. I have been successful incorporating it into my SimpleFormControllers and wizards, however I am having some mapping issues when trying to incorporate it into webflow. Here's what I have working using one of my wizards (non-webflow).

    Code:
    <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    	<property name="interceptors">
    		<list>
    			<ref bean="ajaxInterceptor"/>							
    		</list>
    	</property>
    	<property name="mappings">
    		<props>
    		<prop key="/orderWizard.htm">OrderWizardController</prop>
    		</props>
    	</property>
    </bean>
    
    <bean id="ajaxLoadOfficesHandler" class="com.mktg.form.OrderAjaxActions">
    </bean>
    
    <bean id="ajaxInterceptor" class="org.springmodules.xt.ajax.AjaxInterceptor">
    <property name="handlerMappings">
    	<props>
    	<prop key="/orderWizard.htm">ajaxLoadOfficesHandler</prop>
    	</props>
    </property>
    </bean>

    In web flow I don't see a way to attach an interceptor (in this case AjaxInterceptor) to a specific flow.

    My Flows-Servlet.xml:
    Code:
    <bean name="/orderFlow.flw" class="org.springframework.webflow.executor.mvc.FlowController">
    	<property name="flowExecutor" ref="flowExecutor"/>
    	<property name="cacheSeconds" value="5"/>
    </bean>
    If anyone has had experience using the XT Ajax Framework and Web Flow your help would be greatly appreciated.

    Thanks,

    Keith

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

    Default

    You can have multiple FlowControllers and attach interceptors like that. Then it just boils down to the same style of config as you have now with your "OrderWizardController".

    Also take a look at the shippingrate example that comes with SWF for some SWF-AJAX integration ideas.

    Erwin

  3. #3

    Default Web Flow and Interceptors

    Quote Originally Posted by klr8 View Post
    You can have multiple FlowControllers and attach interceptors like that.Erwin
    Could you elaborate a bit more and perhaps provide an example.

    I have tried the code below, but obviously it fails because the FlowController doesn't have a setter for interceptors.

    Code:
    <bean name="/orderFlow.flw" class="org.springframework.webflow.executor.mvc.FlowController">
    	<property name="flowExecutor" ref="flowExecutor"/>
    	<property name="cacheSeconds" value="5"/>
    	
    	 <property name="interceptors">
    		<list>
    			<ref bean="ajaxInterceptor"/>
                      </list>
    	</property>	
    	
    </bean>	
    
    <bean id="ajaxLoadOfficesHandler" class="com.mktg.form.OrderAjaxActions">
    </bean>
    
    <bean id="ajaxInterceptor" class="org.springmodules.xt.ajax.AjaxInterceptor">
    <property name="handlerMappings">
    	<props>
    	<prop key="/orderFlow.flw">ajaxLoadOfficesHandler</prop>
    	</props>
    </property>
    </bean>
    Thanks,

    Keith

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

    Default

    What I mean is that you can have 2 (or more) Flow controllers, like so:

    Code:
    <bean id="nonAjaxFlows" class="org.springframework.webflow.executor.mvc.FlowController">
    	<property name="flowExecutor" ref="flowExecutor"/>
    	<property name="cacheSeconds" value="5"/>
    </bean>
    
    <bean id="ajaxFlows" class="org.springframework.webflow.executor.mvc.FlowController">
    	<property name="flowExecutor" ref="flowExecutor"/>
    	<property name="cacheSeconds" value="5"/>
    </bean>
    And then have your SimpleUrlHandlerMapping apply interceptors as required:

    Code:
    <bean id="ajaxUrlMappings" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    	<property name="interceptors">
    		<list>
    			<ref bean="ajaxInterceptor"/>							
    		</list>
    	</property>
    	<property name="mappings">
    		<props>
    			<prop key="/ajaxFlows.htm">ajaxFlows</prop>
    		</props>
    	</property>
    </bean>
    
    <bean id="urlMappings" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    	<property name="mappings">
    		<props>
    			<prop key="/flows.htm">flows</prop>
    		</props>
    	</property>
    </bean>
    Erwin

  5. #5

    Default

    Works great! Thanks!

  6. #6

    Default XT Ajax Framework / Web Flow / Command Object

    The issue I am having now is my command object is empty when referenced from an Ajax Event Handler. I understand the Ajax code extends from the BaseCommandController, and web flow does not, and is causing my issue. I was wondering if there is anyway to bridge the gap between the two so that during the flow, when I use an Ajax event handler, I have access to the flows command object.

    During my flow I have a button click that fires off an Ajax Event Handler using the code below.

    .jsp page
    Code:
    <input type="button" value="Press" onclick="doAjaxAction('loadOffices', this);"> 
    <select id="offices">
    <option>--- ---</option>
    </select>
    event handler code (note: orderForm is always null)
    Code:
    public class OrderAjaxActions extends AbstractAjaxHandler{
    	public AjaxResponse loadOffices(AjaxActionEvent event) { 
    		
    	OrderForm orderForm = (OrderForm) event.getCommandObject(); 
    …..
    order-flow-beans.xml
    Code:
    <beans>
    	<bean id="formAction" class="com.mktg.form.OrderFormAction">
    		<property name="formObjectName" value="orderForm"/>
    		<property name="formObjectClass" value="com.hwa.form.OrderForm"/>
    		<property name="formObjectScope" value="CONVERSATION"/>
    		....
    Thanks for your help,

    Keith

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

    Default

    I guess you'll need to lookup the formObject in flow scope from your AJAX event handler. Check the following tip for details on how to do that:

    http://www.ervacon.com/products/swf/tips/tip1.html

    Erwin

  8. #8
    Join Date
    Dec 2006
    Location
    irving
    Posts
    119

    Default

    Hi Erwin
    I am using XT in webflow some how it is throwing the error in the ajaxInterceptor .looks everything is fine.is i am missing anything?


    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean wit
    h name 'ajaxInterceptor' defined in ServletContext resource [/WEB-INF/bpweb-serv
    let.xml]: Error setting property values; nested exception is org.springframework
    .beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
    PropertyAccessException 1: org.springframework.beans.MethodInvocationExceptio n:
    Property 'handlerMappings' threw exception; nested exception is java.lang.NoClas
    sDefFoundError: org/apache/commons/collections/map/MultiValueMap
    Caused by:
    org.springframework.beans.PropertyBatchUpdateExcep tion; nested PropertyAccessExc
    eption details (1) are:
    PropertyAccessException 1:
    org.springframework.beans.MethodInvocationExceptio n: Property 'handlerMappings'
    threw exception; nested exception is java.lang.NoClassDefFoundError: org/apache/
    commons/collections/map/MultiValueMap
    Caused by:
    java.lang.NoClassDefFoundError: org/apache/commons/collections/map/MultiValueMap

    at org.springmodules.xt.ajax.AjaxInterceptor.setHandl erMappings(AjaxInte
    rceptor.java:274)







    Code:
    	<bean id="ajaxBusinessProfileAjaxActions" class="com.idearc.feeos.web.spring.BusinessProfileAjaxActions" >
    	
    	</bean>
    	
    	<bean id="ajaxInterceptor" class="org.springmodules.xt.ajax.AjaxInterceptor">
    	<property name="handlerMappings">
    		<props>
    		<prop key="/bpFlow.htm">ajaxBusinessProfileAjaxActions</prop>
    		</props>
    	</property>
    	</bean>
    
    	<bean id="ajaxUrlMappings" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    		<property name="interceptors">
    			<list>
    				<ref bean="ajaxInterceptor"/>							
    			</list>
    		</property>
    		<property name="mappings">
    			<props>
    				<prop key="/ajaxFlows.htm">ajaxFlows</prop>
    			</props>
    		</property>
    	</bean>
    Thanks
    Venky

  9. #9
    Join Date
    Dec 2006
    Location
    irving
    Posts
    119

    Default

    I figured out the issue. It's due to commons-collections.
    It is failing with the earlier versions. it is working if i use commons-collections-3.2
    Last edited by indone; Mar 21st, 2007 at 08:50 AM.
    Thanks
    Venky

  10. #10
    Join Date
    Jan 2007
    Posts
    11

    Default

    Hi,
    I am trying loadOffice example, the interceptor config is

    <bean id="ajaxLoadOfficesHandler" class="com.hbo.progops.mend.uksvod.service.ajax.Lo adOfficesHandler">
    <property name="store" ref="store"/>
    </bean>



    <bean id="ajaxInterceptor" class="org.springmodules.xt.ajax.AjaxInterceptor">
    <property name="handlerMappings">
    <props>

    <prop key="/uksvod/scheduleHome.uksvod.page">ajaxLoadOfficesHandler</prop>

    </props>
    </property>
    </bean>



    I am getting the exception below. What could be causing it?

    Thanks

    org.springmodules.xt.ajax.support.UnsupportedEvent Exception: Cannot handling the
    given event with id: loadOffices
    at org.springmodules.xt.ajax.AjaxInterceptor.preHandl e(AjaxInterceptor.j
    ava:146)
    at org.springframework.web.servlet.DispatcherServlet. doDispatch(Dispatch
    erServlet.java:788)
    at org.springframework.web.servlet.DispatcherServlet. doService(Dispatche

Posting Permissions

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