views:

1279

answers:

2

Within a spring webflow, i need to implement a navigation bar that will allow to "step back" or resume the flow to one of the previous view.

For example :

  • View 1 = login
  • View 2 = My informations
  • View 3 = My messages
  • View 4 = Close session

For this example, i would like to return back to view 2 from the view 4 page.

+1  A: 

It depends how you're going about doing this. If you're doing this within a single flow, you'll have something like this:

<view-state id="loginView" view="login.jsp">
    <action-state bean="someBean" method="login" />
    <transition on="success" to="informationView" />
</view-state> 

<view-state id="informationView" view="information.jsp">
    <render-actions>
        <action-state bean="someBean" method="retrieveInformation" />
    </render-actions>
    <transition on="forward" to="messageView" />
    <transition on="back" to="loginView" />
</view-state>

<view-state id="messageView" view="message.jsp">
    <render-actions>
        <action-state bean="someBean" method="retrieveMessage" />
    </render-actions>
    <transition on="forward" to="closeView" />
    <transition on="back" to="informationView" />
</view-state>

<view-state id="closeView" view="logout.jsp">
    <transition on="jumpBack" to="informationView" />
</view-state>

The "jumpBack" transition on "closeView" will jump you back to view state #2, which is your information view.

With sub-flows it is tricky. You'd need to chain it: call a subflow, and if an event is signaled that states you need to end your flow with a specific state, immediately do so.

For example, say that your flow chain is login->information->message->close.

On the close flow, the end-state would be "returnToInformation".

The message flow has a transition on="returnToInformation" to="returnToInformation".

"returnToInformation" is also an end-state in the message flow.

Then, the information flow has a transition on="returnToInformation" to="displayInformationPage", which would then re-display the information page.

MetroidFan2002
A: 

I did this by defining some global flow that represented the tabs. I then defined an object that represented the tabs on the flows and indicated if the current tab was active. When the user moved through the tabs I updated the tab object as appropriate.

When the user went to click on one of the tabs it used the global flows to allow them to move between the tabs (for my implementation I found it easier to call actions rather than view states because you may find the views may change depending on the user interaction to get there so you may need to recalculate them).

For the tab bar itself, I put it in a single JSP that I then placed at the top of each form, this made updating it easier.

Its not the nicest solution, but it does work.

Good luck.

Michael Ransley