7 Replies Latest reply on Aug 9, 2010 10:55 AM by nickarls

    Post-redirect and restart conversation with one click

    wangliyu

      This is an old topic if you know Seam2, the application requires to end current LRC and restart a new conversation with one click, in Seam2 there is a trick: you can do Post (end) then redirect (begin new conversation in page action), with CDI, the conversation.end() is actually same with Seam2.x (set the flag to false). but CDI doesn't have Seam page action functionality, I'm wondering if anybody has the same question or someone has already figured out this?

        • 1. Re: Post-redirect and restart conversation with one click
          wangliyu

          actually in JSF2 I found a there is trick to perform page action:




          <f:metadata>
             <f:event type="preRenderView" listener="#{bean.loadAction}" />     
          </f:metadata>



          So it should be possible to do Post-redirect trick with CDI and JSF2.

          • 2. Re: Post-redirect and restart conversation with one click
            wangliyu

            In Weld there is a bean called ConversationManager.



            @Inject
            ConversationManager manager;
            
            @Inject
            Conversation conversation;
            
            
            public string restart() {
                conversation.end();
                manager.cleanupConversation();
                conversation.begin();
            }
            



            I tried with GF3.0.1, it works.


            Can anyone from the Weld team confirm this usage?


            Thanks,
            Liyu

            • 3. Re: Post-redirect and restart conversation with one click
              andygibson.contact.andygibson.net

              Why not end the conversation and do a faces redirect, and in the new page, if there is no conversation, start one using the loadAction method?


              Cheers,


              Andy Gibson

              • 4. Re: Post-redirect and restart conversation with one click
                wangliyu
                I prefer to use post-redirect, but there are several issues with this solution:

                1, it requires the whole page refreshing, in my application, there is only one view (we use AJAX refreshing/replacing some parts of the view), not every components on the page has state mapping on the server side (for example the menu's collapse/expand status).

                2, In JSF2.0 to redirect the page from the action return, you have to add "?faces-redirect=true" to the result, for example:
                   return "home?faces-redirect=true";

                3, we may need run different page load actions at runtime (depends on the menu user selected). and if user selected the menu before redirection, then I have to have something to store the EL and eval it after redirect.
                • 5. Re: Post-redirect and restart conversation with one click
                  pmuir

                  Wang Liyu wrote on Jul 30, 2010 14:26:


                  In Weld there is a bean called ConversationManager.


                  @Inject
                  ConversationManager manager;
                  
                  @Inject
                  Conversation conversation;
                  
                  
                  public string restart() {
                      conversation.end();
                      manager.cleanupConversation();
                      conversation.begin();
                  }
                  



                  I tried with GF3.0.1, it works.

                  Can anyone from the Weld team confirm this usage?


                  Yes, this is the way we intend for you to do this. In Weld 1.1 we will promote this to a user API, and document it.

                  • 6. Re: Post-redirect and restart conversation with one click
                    wangliyu

                    Thanks for answer this, it has been a issue since I started with Seam (I really like CDI), but the ConversationManager class is not in the CDI APIs, are you going to add this to the Spec?

                    • 7. Re: Post-redirect and restart conversation with one click
                      nickarls

                      A proposal has been sent to the EG for possible inclusion in the MR. A long time ago.