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

    Problem stateful beans sharing properties

    mark Auro Newbie

      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.