1 2 3 Previous Next 32 Replies Latest reply on Oct 16, 2008 6:58 PM by luxspes Go to original post
      • 15. Re: Begin and End then Begin in single click

        This is a very interesting issue, I´ve tried it without success. I´ve just voted for it Francisco.

        • 16. Re: Begin and End then Begin in single click

          Thanks. Yes, it is really puzzling.

          • 17. Re: Begin and End then Begin in single click

            Okey, I think I have found a way to prevent users from visiting a page unless it visits it clicking an option in the menu:


            In CategoryList.page.xml (note the conversation-required="false" ):


            <?xml version="1.0" encoding="UTF-8"?>
            <page xmlns="http://jboss.com/products/seam/pages"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.0.xsd"
                  no-conversation-view-id="/Blank.xhtml" conversation-required="false">
                  
               <action execute="#{categoryList.checkSomeCondition}"/>
                  
               <param name="firstResult" value="#{categoryList.firstResult}"/>
               <param name="order" value="#{categoryList.order}"/>
               <param name="from"/>
               <param name="name" value="#{categoryList.category.name}"/>
                 
               <navigation  from-action="#{categoryList.checkSomeCondition}">
               <rule if-outcome="forbidden">
                    <redirect view-id="/Blank.xhtml">
                    </redirect>
               </rule>
               </navigation>
            
            </page>
            
            
            



            In #{categoryList.checkSomeCondition} I return forbidden if the required environment (stuff I need in the conversation) is not ready.


            If things are not ready I get redirected to /Blank.xhtml


            Of course, I do not consider this proper workaround for JBSEAM-3480.


            Mmmm. I wonder what happens if I ask for #{conversation.longRunning}... now that could be a workaround!


            • 18. Re: Begin and End then Begin in single click

              I think I found a workaround, please, someone confirm this:


              If I  implement categoryList.checkSomeCondition like this:


              public String checkSomeCondition(){
                if(!Conversation.instance().isLongRunning())
                   return "forbidden";
                        return "ok";
                }
              



              Then... apparently  I get the behavior I should be getting with conversation-required="true" (and now it is not intermittent, it works as conversation-required="true" should).


              I've been doing this tests in a small test project I'll port this to my big real project and post later in my findings...


              • 19. Re: Begin and End then Begin in single click
                admin.admin.email.tld

                Francisco Peredo wrote on Sep 29, 2008 22:38:


                Hi!
                Basically I have a menu, and each click to the menu starts a conversation (that will have nested conversations and a lot of complex stuff).
                So, when I click this menu, I have to start a conversation, but, if i click another option in the menu, and i am in the middle of the process of the first conversation, I need that conversation ended (if it can not be ended, then I just need to switch to a brand new conversation) and a new conversation started. In other words:

                How can I begin and End then begin (Or Switch the Begin) in single click the conversation?


                I have recently attempted to implement this use case as well for a project and opened a JIRA for this (which was rejected with no explanation and then deleted by the powers that be - you know who you are).  Well, well.  apparently there are others that need to implement the same use case with conversation restart functionality triggered by onchange event of h:selectOneMenu. 


                I was looking for a restart mechanism, or at least being able to end and then start a new conversation.  I've tried Seam conversation API as well as xml directives in pages.xml.  Didn't work.


                My interim workaround solution was to simply set all instance variables in the SFSB to null and use the same LRC.  Seam core API needs to be modified to address this.


                The advice I got from JBoss dev support did not work and I did not receive code samples implementing this scenario...


                for more info, go here

                • 20. Re: Begin and End then Begin in single click

                  Yes, I agree with you that this shouldn't be this hard,
                  in my case the propagation="none" combined with an action with @Begin proposed by Guillaume Jeudy is almost doing the trick, I have already found a workaround for conversation-required="true" and I was starting to celebrate, but now it turns out that there is no easy way to stop page parameter propagation... Any hints on how to do that?

                  • 21. Re: Begin and End then Begin in single click
                    sjmenden


                    but now it turns out that there is no easy way to stop page parameter propagation... Any hints on how to do that?

                    You need to include the param like so:



                    <h:commandButton ... >
                       <f:param name="param1" />
                       <f:param name="param2" />
                    </h:commandButton>
                    




                    ie, there is no great way to disable parameter propagation, so you have to define it without a value like above.

                    • 22. Re: Begin and End then Begin in single click
                      pmuir

                      Sool Chubeshmekh wrote on Sep 30, 2008 21:33:


                      I have recently attempted to implement this use case as well for a project and opened a JIRA for this (which was rejected with no explanation



                      Nonsense. I said If you leave a conversation all objects stored in it will be lost, so the selection will be reset. Please use the forum for support issues like this. Not only was an explanation given as to why it was closed, I even gave you the answer to your question.


                      and then deleted by the powers that be - you know who you are).


                      Not sure why this happened, I will chase it up.

                      • 23. Re: Begin and End then Begin in single click
                        swd847

                        If you want to end the current conversation and begin a new one try this:



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



                        the first line marks the current conversation as ended, it will be destroyed when the request completes.
                        The second line creates a new conversation and switches to it, so now when you call begin() you promote the new conversation to long running, not the conversation that is about to end.

                        • 24. Re: Begin and End then Begin in single click
                          pmuir

                          Stuart Douglas wrote on Oct 02, 2008 06:08:


                          If you want to end the current conversation and begin a new one try this:


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



                          the first line marks the current conversation as ended, it will be destroyed when the request completes.
                          The second line creates a new conversation and switches to it, so now when you call begin() you promote the new conversation to long running, not the conversation that is about to end.


                          Stuart, can you file a feature request for wrapping this up in a single convenience method?

                          • 25. Re: Begin and End then Begin in single click
                            • 26. Re: Begin and End then Begin in single click
                              swd847
                              • 27. Re: Begin and End then Begin in single click

                                Turns out this workaround is insufficient (I think I am hitting this problem)
                                Therefore it needs to be (Yes, one would think asking for long running and nested is redundant, but it turns out it is not):


                                public String checkSomeCondition(){
                                  if(!Conversation.instance().isLongRunning() || conversation.isNested())
                                     return "forbidden";
                                          return "ok";
                                  }
                                
                                

                                • 28. Re: Begin and End then Begin in single click

                                  Sorry I was meaning to write:


                                  public String checkSomeCondition(){
                                    Conversation conversation = Conversation.instance();
                                    if(conversation.isLongRunning() || conversation.isNested())
                                       return "ok";
                                    }
                                    return "forbidden";
                                  
                                  

                                  • 29. Re: Begin and End then Begin in single click
                                    kragoth

                                    This really comes down to the fact that SEAM itself does not provide a clean way of navigating. Pages.xml is fine for people who love the xml world, but you then are string based and this will never really work for a large project anyways.


                                    The real issue is when you want to pass a parameter to another conversation without the current conversation joining it. There are hacky ways to do this, but none are good programming practice.


                                    The @PerNestedConversation annotation is documented saying it basically isn't ready for prod code.
                                    You can't easily use seam to get a different conversation ready and pass params to it.


                                    Ultimately I wrote my own NavigationManager that calls all the right methods in the SEAM api to make navigation work with just code.
                                    Basically it works like this.


                                    Navigation manager has a register of conversations. To get a conversation in the register you call a createController method and pass some seam bean class to it. What this will do is leave the current conversation, make a new one and then instantiate the seam bean in that new conversation. Then make that conversation long running, and register it (internal list). Now we switch back to the original conversation. This method will return the instance of that seam bean that was just created. With this instance you can set all the params you want etc so that when you eventually redirect to its conversation it will have all the data.
                                    I have a bit of infrastructure around all my seam beans so they know which conversation they belong to and now whenever I want to redirect somewhere I just call my NavigationManager.redirect method. (Pass in the conversation id and your done)


                                    This is a really cut down version of what I do.... I'm considering making my code a little more generic and then submitting it to the SEAM guys to see if they can do anything with it. Cause this way of navigating is WAY more flexible and much easier to maintain then any xml or string based navigation.