You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.
| Online: | 22 Members of 4546 |
| Forum: Seam Users |
14. Jul 2008, 18:57 CET | Link |
Hi!
Lets say I am inside 4 levels of nested Conversation, and I have 1 action that, after executing has to end the current nested conversation and redirect me to a particular page. This is easy, I just:
<navigation from-action="#{bienMuebleHomeC.remove}">
<rule>
<end-conversation/>
<redirect view-id="/Inventario/BienMuebleFromC.xhtml"/>
</rule>
</navigation>
Now lets say tha, if certain query parameters are configured in a particular way it should end all nested conversations and the parent long-running conversation and redirect me to another page:
<navigation from-action="#{bienMuebleHomeC.remove}">
<rule>
<end-conversation if ="#{empty bienMuebleFrom}"/>
<end-all-nested-and-main-long-conversation if ="#{not empty bienMuebleFrom}"/>
<redirect view-id="/Inventario/#{empty bienMuebleFrom ? 'BienMuebleListC' : bienMuebleFrom}.xhtml"/>
</rule>
</navigation>
Of course, my problem that <end-all-nested-and-main-long-conversation> does not exist (in fact, I am not sure that is good name for it, it could be a better idea to have something like:
<navigation from-action="#{bienMuebleHomeC.remove}">
<rule>
<end-conversation if ="#{empty bienMuebleFrom}"/>
<end-conversation levels="*" if ="#{not empty bienMuebleFrom}"/>
<redirect view-id="/Inventario/#{empty bienMuebleFrom ? 'BienMuebleListC' : bienMuebleFrom}.xhtml"/>
</rule>
</navigation>
With something like <end-conversation levels="*"> it could even be possible to control how many levels of nested conversations are closed.
Am I right to think that this would be a nice feature to have? (Or is there another better already available way to deal with this in a declarative way?)
Thanks,
Regards,
6 Replies: | |||
|---|---|---|---|
Hi! I wasn't sure if I should post this on JIRA or here, so I posted it in both (if that is wrong just tell me and I will not happen again): Is @End(root=true) the most flexible way to deal with this problem? what if one need to end only 2 or 3 levels of nested conversations, wouldn't it be better if had an option like:
@End(levels="#{3}")
to end all nested conversation (but not root) (regardless of the nesting levels) something like
@End(levels="#{conversation.nestingLevel}")
and, to end the root conversation (regardless of the nesting levels) something like
@End(levels="#{conversation.nestingLevel+1}")
Of course that means we would need to add the nestingLevel to conversation. Regards, I believe that imagination is stronger than knowledge -- myth is more potent than history -- dreams are more powerful than facts -- hope always triumphs over experience -- laughter is the cure for grief -- love is stronger than death. |
|||
And same thing for .pages.xml:
<navigation from-action="#{bienMuebleHomeC.remove}">
<rule if="#{not empty bienMuebleFrom}">
<end-conversation levels="#{conversation.nestingLevel+1}"/>
<redirect view-id="/Inventario/#{empty bienMuebleFrom ? 'BienMuebleListC' : bienMuebleFrom}.xhtml"/>
</rule>
</navigation>
What do you think? I believe that imagination is stronger than knowledge -- myth is more potent than history -- dreams are more powerful than facts -- hope always triumphs over experience -- laughter is the cure for grief -- love is stronger than death. |
|||
Hi! I do not think JBSEAM-1943 is the solution to my problem, because I do not need to end the root conversation, I need to end all nested conversations but keep the root one, at first, I thought that this would work:
private void endRootConversation() {
Conversation conversation = Conversation.instance();
while(conversation.isNested()) {
conversation.root();
}
conversation.endBeforeRedirect();
}
but it obviusly doesnt (as it ends the root of all nested conversations). So, since for now I only need to end 2 levels, I tried with:
private void endRootConversation() {
Conversation conversation1 = Conversation.instance();
conversation.end();
Conversation conversation2 = Conversation.instance();
conversation.end();
}
But it doesn't seem to be working (it seems to be ending only one level of nested conversations). Any hints on how could I end 2 levels? (or simply all nested ones but not the initial long running one?) Thanks, Regards, I believe that imagination is stronger than knowledge -- myth is more potent than history -- dreams are more powerful than facts -- hope always triumphs over experience -- laughter is the cure for grief -- love is stronger than death. |
|||
I am sorry, my second example should have been:
private void endNestedConversations() {
Conversation conversation1 = Conversation.instance();
conversation1.end();
Conversation conversation2 = Conversation.instance();
conversation2.end();
}
Thanks, I believe that imagination is stronger than knowledge -- myth is more potent than history -- dreams are more powerful than facts -- hope always triumphs over experience -- laughter is the cure for grief -- love is stronger than death. |
|||
Finally found the way:
@Override
public String remove() {
String remove = super.remove();
switchToParentConversation();
return remove;
}
private void switchToParentConversation() {
Conversation conversation1 = Conversation.instance();
Manager.instance().switchConversation(conversation1.getParentId());
}
after that, the .page.xml ends the right conversation:
<navigation from-action="#{someEntityHome.remove}">
<rule>
<end-conversation />
<redirect
view-id="someViewId.xhml" />
</rule>
</navigation>
I still feel that this should be solved declaratively with: <end-conversation levels="conversation.nestingLevel"/> Regards, I believe that imagination is stronger than knowledge -- myth is more potent than history -- dreams are more powerful than facts -- hope always triumphs over experience -- laughter is the cure for grief -- love is stronger than death. |
I believe that imagination is stronger than knowledge -- myth is more potent than history -- dreams are more powerful than facts -- hope always triumphs over experience -- laughter is the cure for grief -- love is stronger than death.