1 2 Previous Next 19 Replies Latest reply on May 6, 2008 12:43 PM by corneliuenero Go to original post
      • 15. Re: Chained Comboboxes (selectOneMenu)

        Hi!


        It seems I do not need to put all my bean in ScopeType.PAGE all I have to do is this:


            @Out(required=false,scope=ScopeType.PAGE)
            @In(required=false,scope=ScopeType.PAGE)
            private String masterValue;
        

         


        That way it will not lose the masterValue. (I am still somewhat puzzled and don't quite get how ScopeType.PAGE, but I'll look it to that...


        Regards,

        • 16. Re: Chained Comboboxes (selectOneMenu)
          paata.paatal.magtigsm.ge

          hi again
          i am newbie on seam, but i will try to explain.
          into my task i had wizard like component and i thought that it is good idea to use conversation scope.
          in your case it crashed because you do not have

          join=true

          where you start conversation.


          and what about why @Scope(ScopeType.PAGE) makes it work...
          i can't answer for it, i'm just reading seam reference about components scopes, it is described into chapter 3.


          if i found anything for you i will post.




          _______________________


          Regards


          Paata Lominadze


          Magticom LTD

          • 17. Re: Chained Comboboxes (selectOneMenu)
            barbacena

            Default scope for JavaBeans components is EVENT.

            • 18. Re: Chained Comboboxes (selectOneMenu)
              andygibson.contact.andygibson.net

              I finally got around to trying it with entities instead of strings, and saw the same errors you were getting. I tried it with a javabean and the page scope does work. It also works if you make it conversational and in pages.xml use begin-conversation with join set to true but I know you don't want to do that.


              Your problem is maintaining state across multiple requests which can be solved by using a conversation, or as you have already found, through the PAGE scope. You were asking why, and I really didn't have a good answer (Page scope has been a mystery to many for a while) so I did some investigation.


              Try this, in a page scoped bean, add a counter variable, and a getter method thusly :


                   private int counter = 0;
              
                   ...
              
                   public int getCounter() {
                        return counter++;
                        
                   }
              



              Now add a line of text to your web page :


              <h:outputText value="Counter = #{pageBean.counter}"/>
              



              Now open the page, submit it a few times and the count value keeps going up! We have state!


              At first, I thought this was an error since I thought Page scope kept data around for the whole page request instead of the event/invoke application lifespan. I thought it was re-using the page scoped bean the way stateless EJBs can be re-used by the container.


              However, turns out that this is intended and the page scoped bean maintains state across multiple page requests for the same page. It is like conversation-lite that spans across multiple requests for one page which certainly meets your needs of maintaining the selected items from one page to the next.


              This Link touches on the mysteries of page scope.


              Hope this helps,


              Cheers,


              Andy

              • 19. Re: Chained Comboboxes (selectOneMenu)
                corneliuenero

                don't use s:convertEntity, make a convertor and override equals() and hashCode() for Country and State.


                that's all.

                1 2 Previous Next