6 Replies Latest reply on Feb 5, 2010 5:29 PM by Lawrence Li

    Creating new conversation after the redirect from page action

    Michal Orman Newbie

      Hi all I have following problem.


      I've got component in conversation scope, and I'd like to get the data from that component after the redirect performed as an outcome from page action, something like this:


      <page>
        <action execute="#{component.action}" />
        <navigation from-action="#{component.action}">
          <rule if-outcome="success">
            <redirect view-id="view.xhtml"/>
          </rule>
        </navigation>
      </page>


      In the action I've put some data to conversation scoped component that I want to retrieve after redirect, but there is a problem. When new view is being rendered I've got new conversation scoped component, and my data is simply lost.


      During investigation I've found out that page actions are being invoked somewhere in before render response phase, and somewhere in after render response the new conversation is being created (and new conversation scoped components), after that goes the redirect. So the new view is being rendered with new conversation scoped components. AFAIK the conversation scoped components where designed to survive redirects.


      This problem does not occurs if instead of page action I use normal - let say POST - action. The redirect is done after invoke application and no new conversation scoped components are being created in after render response phase. So the new view is being rendered with conversation scoped components from last request and in after render response phase new components are being created.


      I would expect that no matter which kind of action I use, the behavior should be exact the same. So does Seam shouldn't figure out that it should not remove conversation scoped components if the page action was executed and results in redirect? Or perhaps I'm wrong, and conversation scoped components shouldn't survive redirect from page action?


      Well, I can perform some workarounds (eg. with long-running conversation) but that doesn't solve the problem. Anybody can explain me if I am right or wrong?


      Regards,
      Michal

        • 1. Re: Creating new conversation after the redirect from page action
          Michal Orman Newbie

          Heh, my code snippet doesn't looks like suppose to :)



          <page>
           <action execute="#{component.action}" />
           <navigation from-action="#{component.action}">
             <rule if-outcome="success">
               <redirect view-id="view.xhtml"/>
             </rule>
           </navigation>
          </page>



          It should be well to have preview button :).

          • 2. Re: Creating new conversation after the redirect from page action
            Lawrence Li Newbie
            Hi Michal,

            Did you ever figure out this issue?  I'm running into a similar issue right now where I'm trying to use a page action to determine the page the user will navigate to.  Normally, I would want to do this via a POST action, specify a particular page to navigate to (and the page action would not ultimately determine the page to navigate to).  But my issue is fairly similar.  However, I'm trying to do some "unconventional" stuff on a portlet (Liferay/Seam/ICEfaces) and a user entering a URL with page parameters.  I've experienced the same issue you have.  My situation is slightly different because I'm using a portlet so I'm using a render rather than a redirect.  I've tried starting a long-running conversation - but as you've experienced, Seam ignores this and creates new conversation scoped components.  I've tried starting a long running conversation in *.page.xml and programatically via Conversation.instance().begin().  Actually, Liferay bombs out when I try to specify it as a long running conversation.
            • 3. Re: Creating new conversation after the redirect from page action
              Ilya Dyoshin Novice

              Well As I understood: SEAM has 2 types of conversations, and actually almost everything is SEAM is in CONVERSATION. If you haven't started long-running conversation SEAM creates temporal conversation in which it injects all components used in the current page, unless some action Moves the conversation from temporal to long-running conversational context, each component is recreated, like if they were in the PAGE scope.


              you can simply add <begin-conversation join="true" /> in your original page (i.e. which the initial data inputed), and by default SEAM will prolongate your conversation through your navigation, unless you leave this conversational context with specifying different conversationId (cid by default) or anything else.



              Regards,


              Ilya Dyoshin.

              • 4. Re: Creating new conversation after the redirect from page action
                Lawrence Li Newbie

                Hi Ilya,


                I've actually tried before and it does not work.  I'm testing the situation when a user enters the URL manually on the browser location bar...  The conversation scoped component set in the page action doesn't seem to be propagated...

                • 5. Re: Creating new conversation after the redirect from page action
                  Ilya Dyoshin Novice

                  are you starting a long-running conversation in the page where user enters?


                  for my application I'm adding <begin-conversation join="true"/> to almost every page from CRUD interfaces (maybe wrong design but it works, and there is small amount of users for application). the only pages which don't have that - are those involved in pageflows.  Thus users can resend the urls each-other and everything works fine !




                  • 6. Re: Creating new conversation after the redirect from page action
                    Lawrence Li Newbie

                    Yep, I'm starting a long-running conversation.


                    I did notice a very important point though.  I tried a few things - and it looks like it's failing for me when I try to inject and outject a Home object.  However, if I inject/outject a non-Home object, then it's OK.  I'm thinking I must be doing something silly or I'm overlooking an important concept.  Here's a sample snippet I'm testing:


                    @In(create=true)
                    @Out
                    private ItemHome itemHome;
                    
                    public void pageAction {
                           itemHome.setId(1L);
                    }



                    Is there something with Home objects and their invocation/injection/outjection in page actions I should know about - and is there a limitation in a portlet environment (Seam/ICEfaces/Liferay)?