Announcement Announcement Module
Collapse
No announcement yet.
Partial rendering and FlowExecutionExceptionHandler Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Partial rendering and FlowExecutionExceptionHandler

    Say I have a flow like that, using a transition without a target and partial rendering:

    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="start" view="view" model="model">
    		<transition on="command">
    			<evaluate expression="bean.method(parameter)" result="flowScope.result" />
    			<render fragments="fragment1,fragment2" />
    		</transition>
    	</view-state>
    	
    	<end-state id="error" view="externalRedirect:/error"/>
    	
    	<exception-handler bean="exceptionHandler" />
    </flow>
    I'm trying to redirect the user to a different flow in case of an error using my exceptionHandler when an exception occurs in the "bean.method" call. The handler simply triggers a transition to the "error" end-state shown above which should redirect the user into a different flow then.

    Code:
    public class ExceptionHandler implements FlowExecutionExceptionHandler {
    	@Override
    	public boolean canHandle( FlowExecutionException exception ) {
    		return ExceptionUtils.getRootCause( exception ) instanceof MyException;
    	}
    
    	@Override
    	public void handle( FlowExecutionException exception, RequestControlContext context ) {
    		context.execute( new Transition( new DefaultTargetStateResolver( "error" ) ) );
    	}
    }
    What I experience, though, is that the current view is re-rendered. I believe this is due to the partial rendering which seems to be overruling the new transition. I stepped through the "handle" method to make sure it gets called and the execution of this transition went well, too.

    Any hints? Thanks!

    - hd

  • #2
    As always, it takes ages to find a possible solution, and then you come across one minutes after you finally posted a question in your despair....

    It appears to be working when I add a
    Code:
    context.removeCurrentFlowExecutionSnapshot();
    before the context.execute call.

    But I'm wondering whether this is the correct way to handle such a situation?

    Thanks!
    - hd

    Comment


    • #3
      Here's a f'up on my question (maybe I'll find the solution immediately after posting this again...).

      When I have an event like below, I remain in the current view state. When I add messages in the method called in the expression, they get displayed afterwards.

      Code:
      <view-state ...>
      	<transition on="action">
      		<evaluate expression="bean.method()" />
      	</transition>
      </view-state>
      As far as I can see from the code, an event is basically a transition without targetStateResolver.

      When I try this in an exception handler, however, I get an empty page:

      Code:
      public class ExceptionHandler implements FlowExecutionExceptionHandler {
      
      	// ...
      
      	@Override
      	public void handle( FlowExecutionException exception, RequestControlContext context ) {
      		context.execute( new Transition() );
      	}
      }
      What's the correct way to mimic the transition behavior above?

      Thanks!

      - hd

      Comment

      Working...
      X