1 2 3 4 Previous Next 46 Replies Latest reply: Jul 19, 2012 5:26 PM by Tim Evers RSS

How to end and begin a new conversation with one signle <s:link>

Wang Liyu Novice
Hi, in my app, I need to end the previous long-run conversation and begin a new long-run conversation with one single click, I have tried the s:link and seems it doesn't work that way, so far I have tried to use @End & @Begin on the same method, use @RaiseEvent on the @Destroy method and @Observe on @Begin, use seam api:

Conversation.instance().end();
Manager.instance().initializeTemporaryConversation();
Conversation.instance().begin();

and also use <s:link action="#{conversation.begin}" propagenate="end"> and none of them worked.

Does anyone find a work around?

I tried to use propagenate = "none", it does create a new conversation, but the old one is not change to temp conversation.

-------------------

By the way, seam should support "@ReBegin" or "@Begin(closebefore = true)", for the real app, sometimes we really need this functionality.
  • 1. Re: How to end and begin a new conversation with one signle <s:link>
    Yasser Hawari Newbie

    that is a strange requirement!.


    try annotating the function that should start a conversation with




    @Begin (join = false) 





    and use the s:link to call this function and end the current one conversation. theoretically, that should work i guess !!.

  • 2. Re: How to end and begin a new conversation with one signle <s:link>
    Wang Liyu Novice
    This is totally not a strange requirement, say in my applications, there is a top menu, each menu item can lead to a set of wizard style pages (conversation), user can click other menu item in the middle of the steps, so app should be able to end the current conversation and start a new one when user click the menu item, you shouldn't force the user to click twice when the user in the middle of the steps.

    BTW, I tried use @Begin (join=false), if the previous conversation is not explicit close, you will get exception, I don't think your way works. if use propagation="end", it will reuse the current conversation, if use propagation="none", it will create new one, but the old one still keeps a long run status util timeout, which I don't want to see (timeout is OK for small amount of user, if huge number of user doing that kind of thing, it may kill the server).
  • 3. Re: How to end and begin a new conversation with one signle <s:link>
    Susanne Jarl Newbie

    There are more people having the same problem, me for instance. You can read more here: http://seamframework.org/Community/ProblemEndingConversationInRichFacesMenuItem

  • 4. Re: How to end and begin a new conversation with one signle <s:link>
    Adrian Mitev Master

    The following


    Conversation.instance().leave();
    Conversation.instance().begin();
    



    works for me. But if I use end() it does't. I would like if any of the Seam team explain how to solve such usecases.

  • 5. Re: How to end and begin a new conversation with one signle <s:link>
    Arbi Sookazian Master

    I had a use case a while back that required the current LRC to end and begin a new LRC onchange event of HtmlSelectOneMenu.


    The JIRA I opened for this was rejected and closed by PMuir.  Don't recall the explanation (I don't think he really gave a technical reason).


    This is a very good question.


    And you gotta love how the Seam core dev team ignores most of the posts on this forum.


    Great community!

  • 6. Re: How to end and begin a new conversation with one signle <s:link>
    Wang Liyu Novice
    Hi, Thanks for replying my post, the "Conversation.instance().leave()" is same with "propagation="none" I believe. I tried this too, it still not change the old long run conversation to temp. I'll do some more investgating. and Hope the seam team can listen more on the users, hope seam can be easier to use.
  • 7. Re: How to end and begin a new conversation with one signle <s:link>
    Gustavo Costa Newbie

    Hi Liyu.1


       I had that same problem and my solution is...





    <s:link action#{testBean.test} value="Simple Test"  propagation="none"/>



    or


    <rich:menuItem action="/test/test.xhtml" value="Simple test" >
                        <s:conversationPropagation type="none"/>
                   </rich:menuItem>



    It work's for me...

  • 8. Re: How to end and begin a new conversation with one signle <s:link>
    Wang Liyu Novice
    Hi,
    THanks for replying my question, the 'propagation="none"' will leave the old long run conversation until timeout which I don't really want to see, user can kill the application by keep click the menu item and make the server die eventually.
    In the application, I don't need to switch the conversation, once user leave the conversation, it leave forever.
    I tried to set the conversation's timeout = 0 and it doesn't work either.

    Is there any easy solution there?
  • 9. Re: How to end and begin a new conversation with one signle <s:link>
    Wang Liyu Novice
    Hi,
    this is working and ugly, hope Seam team can provide a clean & working built-in function:

    Here is my code:

    @Name("ConversationHelper")
    @Scope(ScopeType.SESSION)
    @BypassInterceptors
    public class ConversationHelper implements Serializable {

        private static final long serialVersionUID = -5199645560962980226L;

        @Logger
        private Log logger;

        public void restart() {
            String convID = Conversation.instance().getId();
            logger.info("leave conversation {0}", convID);
            Conversation.instance().leave();
            Conversation.instance().begin();
            Lifecycle.destroyConversationContext(getSessionMap(), convID);
            ConversationEntries.instance().removeConversationEntry(convID);
        }

        private Map<String, Object> getSessionMap() {
            // this method could be moved to a utility class
            Map<String, Object> session = new HashMap<String, Object>();
            String[] sessionAttributeNames = Contexts.getSessionContext().getNames();

            for (String attributeName : sessionAttributeNames) {
                session.put(attributeName, Contexts.getSessionContext().get(attributeName));
            }
            return session;
        }
    }

    And then in the page:

    <s:link id="menuDumberId" view="/dumber.xhtml" action="#{ConversationHelper.restart}" value="UglyMenuItem" rendered="#{identity.loggedIn}"/>

    And it will recreate new conversation (different ID) and cleanup the ConversationEntries evertime you click it.

    Need to test it carefully though.

    Liyu
  • 10. Re: How to end and begin a new conversation with one signle <s:link>
    Wang Liyu Novice

    Also I found that there is a method in the conversation called : killAllOthers(), if this method is called, all the conversation except who fired this method will be cleanup, even it belongs to different Session, I suppose this method should only remove all the conversations that belongs to the same session, is this a Bug?

  • 11. Re: How to end and begin a new conversation with one signle <s:link>
    Pete Muir Master

    @End(beforeRedirect=true) for this purpose. No, there is no way to end and start a new conversation without doing a redirect, and no, we aren't planning to implement such a function in core Seam. Someone should write a wiki article showing how to do this, with a custom component :-)

  • 12. Re: How to end and begin a new conversation with one signle <s:link>
    Wang Liyu Novice
    Hi Pete,
    I tried to use "@End(beforeRedirect=true)" and combined with @Begin or trigger event to call @Begin method,

    also I tried:
    <s:link action="#{conversation.begin}" ... propagation="end">

    None of them worked, best I can get is that the old LRC is waiting for timeout and the new LRC one started.

    I see other peoples have the same problem, could you please write a wiki or blog to show me how to do this trick?

    I'm trying to apply seam in the new project and I'm new to this framework, maybe there are some misunderstanding, can you explain why seam can't implement this?

  • 13. Re: How to end and begin a new conversation with one signle <s:link>
    Wang Liyu Novice
    Hi Pete,
    I figured out (kind of), in the page.xml:
         <page view-id="*" login-required="false">
              <navigation>
                   <rule if-outcome="non-conversation">
                        <end-conversation before-redirect="true" root="true" />
                        <redirect view-id="/home1.xhtml" />
                   </rule>
                   <rule if-outcome="conversational">
                        <end-conversation before-redirect="true" root="true" />
                        <redirect view-id="/home2.xhtml" />
                   </rule>
              </navigation>
         </page>
         <page view-id="/home2.xhtml" login-required="true">
              <begin-conversation join="true" />
         </page>

    and in the page, use <s:link id="menuMemberId" action="conversational" value="Test" rendered="#{identity.loggedIn}" />

    it works, but if it's ajax request like :

    <rich:panelMenuItem action="deposit" label="Deposit"></rich:panelMenuItem> combined with <a4j:outputPanel ajaxRendered="true">,

    This could lead some trouble.
  • 14. Re: How to end and begin a new conversation with one signle <s:link>
    Arbi Sookazian Master

    Pete Muir wrote on Jun 09, 2009 14:50:


    @End(beforeRedirect=true) for this purpose. No, there is no way to end and start a new conversation without doing a redirect, and no, we aren't planning to implement such a function in core Seam. Someone should write a wiki article showing how to do this, with a custom component :-)


    At least 90% of the Seam developer community is composed of beginners (and yes, that's 3 years after the relesae of 1.0.0.GA!).  It's very lame to ask (mostly) novices to write a wiki when surely the Seam core dev team should.  Esp. for something that seems to be this important/popular.

1 2 3 4 Previous Next