This content has been marked as final.
Show 5 replies
-
1. Re: Ending multiple nested conversations?
antispart Dec 6, 2006 12:43 PM (in response to antispart)It looks like this may be what I want (?)
if (...) { Conversation.instance().end(); Conversation.instance().leave(); }
-
2. Re: Ending multiple nested conversations?
gavin.king Dec 6, 2006 12:45 PM (in response to antispart)No, but you can add a feature request to JIRA if you like.
-
3. Re: Ending multiple nested conversations?
antispart Dec 6, 2006 1:07 PM (in response to antispart)Done, thanks:
http://jira.jboss.com/jira/browse/JBSEAM-566 -
4. Re: Ending multiple nested conversations?
vralev Apr 22, 2007 6:15 AM (in response to antispart)Here is my solution:
Add this method to org.jboss.seam.core.Manager/** * End a conversation together with all nested conversations. The * conversation passed in cid will be destroyed at the end of the * request while the nested conversations are destroyed immediately. * * @param cid the ID of the conversation */ public void endConversationByID(String cid, boolean beforeRedirect) { log.debug("Ending long-running conversation"); if ( Events.exists() ) Events.instance().raiseEvent("org.jboss.seam.endConversation"); ConversationEntries ce = (ConversationEntries) Component.getInstance("org.jboss.seam.core.conversationEntries"); setCurrentConversationId( cid ); setCurrentConversationIdStack( ce.getConversationEntry( cid ).getConversationIdStack()); setLongRunningConversation( false ); destroyBeforeRedirect = beforeRedirect; endNestedConversations( cid ); storeConversationToViewRootIfNecessary(); }
In the bean do this:public String endParent() { Manager m = (Manager)Component.getInstance("org.jboss.seam.core.manager"); m.endConversationByID(Conversation.instance().getParentId(), false); return "next.seam"; } //Assuming conversations 1->2->3 public String endParentOfParent() { Manager m = (Manager)Component.getInstance("org.jboss.seam.core.manager"); // kill immediately 3, set Conversation.instance() to 2 and mark it to // be ended at the end of the request m.endConversationByID(Conversation.instance().getParentId(), false); // kill immediately 2, set Conversation.instance() to 1 and mark it to // be ended at the end of the request m.endConversationByID(Conversation.instance().getParentId(), false); return "next.seam"; }
The endParent() kills the current conversation immediately and the parent at the end of the request. If you want to kill the parent of the parent too, you can call endConversationByID against Conversation.instance().getParentId() because the current Conversation instance is actually the conversation scheduled to be destroyed at the end of the request. -
5. Re: Ending multiple nested conversations?
vralev Apr 22, 2007 9:43 AM (in response to antispart)Actually it's better to use the instance methods
/** * End a conversation together with all nested conversations. The * conversation passed in cid will be destroyed at the end of the * request while the nested conversations are destroyed immediately. * * @param cid the ID of the conversation */ public void endConversationByID(String cid, boolean beforeRedirect) { log.debug("Ending long-running conversation"); if ( Events.exists() ) Events.instance().raiseEvent("org.jboss.seam.endConversation"); ConversationEntries ce = ConversationEntries.instance(); setCurrentConversationId( cid ); setCurrentConversationIdStack( ce.getConversationEntry( cid ).getConversationIdStack()); setLongRunningConversation( false ); destroyBeforeRedirect = beforeRedirect; endNestedConversations( cid ); storeConversationToViewRootIfNecessary(); }
withpublic String endParent() { Manager m = Manager.instance(); m.endConversationByID(Conversation.instance().getParentId(), false); return "next.seam"; } //Assuming conversations 1->2->3 public String endParentOfParent() { Manager m = Manager.instance() // kill immediately 3, set Conversation.instance() to 2 and mark it to // be ended at the end of the request m.endConversationByID(Conversation.instance().getParentId(), false); // kill immediately 2, set Conversation.instance() to 1 and mark it to // be ended at the end of the request m.endConversationByID(Conversation.instance().getParentId(), false); return "next.seam"; }