Reputation: 7395
I have a wizard in my Seam project which has four pages. When user starts the wizard by coming to the first page (wizard1.xhtml) I start a conversation. To do that in my pages.xml
I have following code.
<page view-id="/pages/wizard1.xhtml">
<begin-conversation join="true"/>
</page>
At the final page of the wizard (wizard4.xhtml) I have a save button and I end the conversation by using @End
annotation.
@End
public String save() {}
However while moving through the wizard, the user can redirect to a page outside the wizard by clicking a link. Note that if this happens the conversation is not yet ended.
What I want is to immediately end the conversation as soon as the user is no longer on a wizard page (wizard1.xhtml,wizard2.xhtml,wizard3.xhtml or wizard4.xhtml).
I found this post but a timeout is not a good choise in my case since I want to end the conversation immediately.
Upvotes: 0
Views: 1874
Reputation: 193
If you are using pages.xml (or the per-page page.xml files) to implement page navigation in your application, then you have to specify redirect behavior, for each page, based on the action string. In the navigation rule for each redirect that is not continuing your wizard conversation, you can add <end-conversation />
. This is similar to other suggestions, but the result would be navigation rules files which illustrate your applications page flow including the demarcation of your long-running conversations.
Upvotes: 0
Reputation: 7126
I think the most straight forward and natural solution of your problem is to make your click-able link like this:
<s:link value="here is the link" view="/expectedView.xhtml"
action ="#{targetBean.endingConversation()}"/>
And your endingConversation() method can be like this:
@End
public void endingConversation(){
//do cleanup code
}
The idea is simple, you should employ a guard in every possible exiting points.
Upvotes: 2
Reputation: 725
Not sure if it will work, just a thought.
Create some javascript function using a4j:jsFunction
that calls a method that's annotated with @End
.
You then add this jsFunction
as an onClick
handler to all Your links. (Not sure if onClick
is the best handler though).
When the user navigates away from Your wizard the method is called and the conversation should be ended.
Upvotes: 1