0

I am using spring web flow 2.x and is trying to append the view state id to the URL. I want to save the view state id to request scope and append it to URL everytime user clicks 'next' or 'previous'. Is this possible using a Custom Flow URL handler?

How do I get the view state Id inside my Custom/Pretty flow Url handler?

mi3
  • 581
  • 1
  • 7
  • 13

1 Answers1

0

Write an on-entry action in the view and retrieve current state id by RequestContext.

<view-state id="currentView" view="currentView" model="modelObject">
    <on-entry>
        <evaluate expression="yourObject.methodName(flowRequestContext, flowScope.modelObject)"/>
    </on-entry>
    <transition on="previous" to="someStateOrView"/>
    <transition on="next" to="someStateOrView"/>
 </view-state>      

 public class YourObject{
...
public void methodName(RequestContext requestContext, ModelObject model){
    model.setPreviousView(requestContext.getCurentState().getId());
    ....
}
 }

Get the previousView value from your model and append it to your url as this will be set the moment flow enters into this view.

Prasad
  • 3,785
  • 2
  • 14
  • 23
  • But how do I get the view state appended to the URL in my Custom Flow URL handler. I am using the example from here.[http://forum.spring.io/forum/spring-projects/web/web-flow/81719-urlrewrite-and-spring-web-flow] – mi3 Mar 21 '14 at 02:58
  • In other words, how do I get the request context in my Flow Url Handler? – mi3 Mar 21 '14 at 03:26
  • RequestContext requestContext = RequestContextHolder.getRequestContext(); String viewName = requestContext.getCurrentState().getId(); – Prasad Mar 21 '14 at 15:09