9 Replies Latest reply on Apr 30, 2009 7:46 PM by dan.j.allen

    Context Management

    diegocoronel

      Hi people,


      I would like to know IF the implementation of the conversation context on webBeans will use the same idea of SEAM.. I want to know if we will always have a temporary conversation for each request, the developer will only promote or remove the conversation in relation with a long-running one?. Actually when we finish a conversation at seam with


      before-redirect = true




      ..  even the context variables of the event are lost at the moment of the page renderization. My difficulty is that I would like to associate JSF facesMessage to my event context, this way if facesmessages wasn’t associated to the current conversation I could finish the conversation with before-redirect true and show a message to the user because the response would be associated to the current event. This way i can always finish the conversation and be with my request context variables to rerender the current request.

        • 1. Re: Context Management
          nickarls

          The specs speaketh:


          • By default, a conversation is transient
          • A transient conversation may be marked long-running by calling Conversation.begin()


          So it will be seamish as I understand it.

          • 2. Re: Context Management
            diegocoronel

            Hi Nicklas,


            What i really wanna know is when i do a web submit will my variables in event context be associated to current conversation context? Because with seam i tried to outject or use a component in event scope and end conversation before redirect... it seems that i cant use my event variables on render phase, just because my conversation was ended before redirect. Is it expected ?


            Sry about english. :)

            • 3. Re: Context Management
              nickarls

              Ummm. I must confess that it exceeds my seam-knowledge.


              I do know that the seam-team will try to make Seam3 as backward compatible to Seam2 as possible (increasing functionality where possible under the new core). Perhaps Pete has a comment if he happens to read this.

              • 4. Re: Context Management
                pmuir

                Sounds like strange behaviour in Seam. Most of the conversation stuff in Seam will eventually end up in Web Beans.

                • 5. Re: Context Management
                  diegocoronel

                  Hey Peter,


                  We should expect same behaviour in web beans ?


                  Im asking because i wanna to do something like this in my code:


                  myBean {
                   Entity sample;
                   public String save(){
                     persist(sample);
                     FacesMessages.get..().addMessage ("success"); 
                     conversation.end(); 
                   }
                  }



                  where i wanna FacesMessages in my event context, this way is possible to show to user the success message and developer dont need to make any kind of method to clear variables... because he is going to redirect to start page of conversation. Getting a new conversation id with success message showing.


                  So, i tried this in Seam and it not work.. in web beans will this be possible ?


                  sry. about english

                  • 6. Re: Context Management
                    pmuir

                    Actually, I probably misread your message, what you are trying to do won't work, the event context isn't propagated across a redirect.


                    In JSF2 the faces message are stored in a flash scope anyway.

                    • 7. Re: Context Management
                      diegocoronel

                      Hi Pete,


                      It sounds perfect, is it a new kind of context to be used ? can we put any of our variables in this flash context? Can we have this on seam ?


                      ty.

                      • 8. Re: Context Management
                        pmuir

                        Diego Coronel wrote on Feb 06, 2009 13:52:


                        Hi Pete,

                        It sounds perfect, is it a new kind of context to be used ? can we put any of our variables in this flash context? Can we have this on seam ?

                        ty.


                        Yes, yes and no, just use JSF2.

                        • 9. Re: Context Management
                          dan.j.allen

                          Actually, there is a problem in JSF 2, which we can easily work around in Seam (what else is new?). The default behavior in JSF 2 is to not bind FacesMessages to the flash scope on a redirect. You have to explicitly call FacesContext.getCurrentInstance().getExternalContext().getFlash().setKeepMessages(true). I know. My thought too. So anyway, it is ludicrous not to want to do this all the time, so guess what? We will revert this default in Seam. I'm testing it now in the booking example in Seam 3.