Leaving the long-running conversation programatically in the action method turns out to be no solution: Seam's ConversationInterceptor throws an IllegalStateException before the method is executed, because the @Begin annotation doesn't specify "join=true". I could try to work around this by registering another action listener to the command button, which fires before the main action method, and which leaves the conversation. That makes the construction even more artificial.
Anyone who knows an elegant solution?
I have a similar problem and i am quite new to Seam. Has anyone a solution ?
marcelkolsteren could you please explain how you did it using the API ?
Thanks for the input. It is what i was looking for.
However, it is strange that there is no direct support for this... I was wondering if using one big top level conversation then nested conversations couldn't do the job (i am a noob, remember :) ?
In fact, my problem is to manage workspace a la eclipse (http://jboss.com/index.html?module=bb&op=viewtopic&t=130054).
If someone from the Seam team may answer to that question, it will be a real help!
We faced a similar situation a few days ago. The user could click on a hyperlink in a page to go to a different page which was required to open in a new non-nested conversation. Before redirecting to the new page, the application was required to process the edits the user had made on the screen, save those changes and not end the conversation (instead, leave the conversation since the user could come back to the first page by back buttoning from the 2nd page).
The solution we went with was:
1. On the JSP page, use <h:commandLink> to post the form data back to the server so that the POST will propagate conversation.
2. Process the form submit using standard JSF phases.
3. Determine which page to redirect the user to.
4. In phase V, return the navigation constant corresponding to the 2nd page.
5. In pages.xml, use:
<raise-event type="leaveConversation" />
6. Define an event listener for leaveConversation event. In the @Observer method for this event, do as follows:
ii. Get conversation entry for the Conversation object and call unlock() on it.
This worked perfectly. I know this is not an ideal solution.
We would like to suggest that Seam team support ability for specification of a tag like <leave-conversation> in pages.xml (similar to <begin-conversation> and <end-conversation>). That will be the ideal solution to this problem.
Thanks for presenting your solution to a similar problem. We share the hope for attention of the Seam team to these conversation switching issues. In your case, the new conversation only starts after the redirect, in the next request. That makes a big difference. I need to switch to another conversation inside an action method, and I would like the new conversation to be active in the render response phase, without redirecting. So the ideal solution that you present won't help me out.
Marcel, now that it has been a solid 4 years since your post your blog link is no longer up to date. Any chance you have your solution posted somewhere else?
A "solution" we came up with was to use a redirect call within the action method. I don't know if we will encounter any issues in regards to moving on before Seam may or may not have had opportunity to complete any of its tasks (e.g., flushing contexts, etc)