3 Replies Latest reply on Feb 8, 2008 5:17 AM by markauro

    Problem stateful beans sharing properties

    markauro

      Hello,

      I'm using JBoss 4.2.2GA with Seam 2.0.1.CR1, i've started my seam application using Booking example as a template, so i have a stateful bean that make a search into de DB (using the EntityManager) and get a list of Entities like the HotelSearchingAction.

      This is my stateful bean:

      @Stateful
      @Name("operationList")
      @Scope(ScopeType.SESSION)
      public class OperationListAction implements IOperationList {
      
       @Logger
       private Log log;
      
       @PersistenceContext(type=PersistenceContextType.EXTENDED)
       private EntityManager em;
      
       private Operation operacionForm;
      
       @DataModel
       private List<Object> resultList;
      
       @DataModelSelection
       private Operation operacion;
      
      
       private int pageSize = 10;
       private int page = 0;
       private int numPages = 0;
       private String order = "";
      
       ......
      }
      


      It was running well, but i made another stateful bean that make a different search with different name, same scope, and the same properties (page, pageSize, etc..).
      For my surprise, it seems to be sharing te properties that has identical names and types between the beans, so if i make a search and go to de 2nd page, changing the page number in one of the stateful bean, then making a search using the other bean initially displays the 2nd page as well.

      The other stateful bean:

      @Stateful
      @Name("companyList")
      @Scope(ScopeType.SESSION)
      public class CompanyListAction implements ICompanyList {
      
       @Logger
       private Log log;
      
       @PersistenceContext(type=PersistenceContextType.EXTENDED)
       private EntityManager em;
      
       private Company companyForm;
      
       @DataModel
       private List<Object> resultList;
      
       @DataModelSelection
       private Company company;
      
      
       public int pageSize = 10;
       public int page = 0;
       public int numPages = 0;
       public String order = "";
      
       ......
      }
      


      Is this the default behavior? or i am doing somethig wrong, perhaps the configuration is not the best for this porpouse...

      I am a rookie whith seam, so any suggestion is welcome.


        • 1. Re: Problem stateful beans sharing properties
          markauro

          Please, this is making me go mad.... can anybody tell me something about this question ??
          Thanks.

          • 2. Re: Problem stateful beans sharing properties
            dexjam

            Try renaming the @Datamodel variable, probably seam looks up the same List over and over again.

            • 3. Re: Problem stateful beans sharing properties
              markauro

              Thanks dexjam,
              yes, i just tried renaming the @Datamodel variable, and it works, seam create a different instance, but i have to rename all the bean variables so each bean has different properties names... what is supposed i need to do if i've so many pages that make searchs of different things, i would rename all the properties in each action-bean... but they do the same action, this doesn't seems to be a pretty way.
              I think nobody has this problem because all the posts i have seen talk about the opposite problem, people trying to share a variable between stateful/stateles beans, like if you put it directly into the session and then you retrieve form another action-bean...
              ok, i have the answer !! its inside my application :-)