Page 2 of 2 FirstFirst 12
Results 11 to 11 of 11

Thread: OpenSessionInView Interceptor doesn't work with Spring Webflow

  1. #11

    Default

    Great, it worked!!

    I have defined the /mvc/* prefix for all my controllers and the flows still reside on /* (as I now, there is no way for setting a custom prefix for flows as you suggested).

    The SWF configuration would be like this:
    Code:
    	<!-- Creates a flow executor in Spring, responsible for creating and executing flows -->
    	<flow:flow-executor id="flowExecutor" flow-registry="flowRegistry">
    		<flow:flow-execution-listeners>
    			<flow:listener ref="jpaFlowExecutionListener" />
    		</flow:flow-execution-listeners>
    	</flow:flow-executor>
    	
    	<!-- Listener for the JPA execution listener -->
    	<bean id="jpaFlowExecutionListener" class="org.springframework.webflow.persistence.JpaFlowExecutionListener">
    	    <constructor-arg ref="entityManagerFactory" />
    	    <constructor-arg ref="transactionManager" />
    	</bean>
    	
    	<!-- Load flow definitions and make them available to the flow executor -->
    	<flow:flow-registry id="flowRegistry">
    		<flow:flow-location id="process-flow" path="/process/flows/process-flow.xml" />
    		<flow:flow-location id="phase1-flow" path="/process/flows/phase1/phase1-flow.xml" />
    	</flow:flow-registry>
    	
    	<!-- The FlowHandlerMapping helps DispatcherServlet to knowing that it should send flow requests to Spring Web Flow -->
    	<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
    		<property name="flowRegistry" ref="flowRegistry" />
    	</bean>
    	
    	<!-- The FlowHandlerAdapter is equivalent to a Spring MVC controller in that it handles requests coming in for a flow and processes those requests -->
    	<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter">
    		<property name="flowExecutor" ref="flowExecutor" />
    	</bean>
    And the OpenEntityManagerInViewFilter configuration would be like this:
    Code:
    	<filter>
    		<filter-name>oemInViewFilter</filter-name>
    		<filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
    		<init-param>
    			<param-name>entityManagerFactoryBeanName</param-name>
    			<param-value>entityManagerFactory</param-value>
    		</init-param>
    	</filter>
    	
    	<filter-mapping>
    		<filter-name>oemInViewFilter</filter-name>
    		<url-pattern>/mvc/*</url-pattern>
    	</filter-mapping>
    I hope it helps anybody...

    At the same time, though it works I don't like the solution at all because I don't like to use such pattern for controller's URLs, in my opinion is a little bit ugly (yes, I am too meticolous ). Would be nice to have a single point for configuring open session in view behaviour both for MVC and SWF, and I don't know if such configuration option exists...

    Anyway thousand of thanks emil1, if I can't find my "perfect solution" I will do it your way .

    Regards and have a nice weekend.
    Last edited by alejandrogarciaseco; Jul 27th, 2012 at 09:04 AM. Reason: typo

Tags for this Thread

Posting Permissions

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