3 Replies Latest reply on Sep 7, 2007 8:57 AM by yohann49

    Facotry-session and bean-conversation

    yohann49

      Hello !

      I was wondering if it could be possible to have a bean wich his scope is CONVERSATION and a fctory in this bean whis his scope is SESSION. I want to do that but when I want to go to the xhtml page, I have this exception :

      Exception during request processing: javax.servlet.ServletException: factory method with defined scope outjected a value: orders

      My bean :

      
      @Stateful
      @Name("ListOrder")
      @Scope(CONVERSATION)
      public class OrderManager implements OrderManagerLocal, Serializable {
      
      @DataModel("orders") List<Order> orders;
      
      @Factory(value="orders", scope = SESSION)
       public void findOrder(){
      
       Query query;
      
       query = em.createQuery("select o from Order o where o.customer=#{currentContact.customer}");
      
      
       orders = (List<Order>) query.getResultList();
      
      
       }
      }
      


      Thanks Yohann

        • 1. Re: Facotry-session and bean-conversation
          pmuir

          Not with @DataModel, you could just @Factory e.g.

          @Stateful
          @Name("ListOrder")
          @Scope(CONVERSATION)
          public class OrderManager implements OrderManagerLocal, Serializable {
          
          @Factory(value="orders", scope = SESSION)
           public void findOrder(){
          
           Query query;
          
           query = em.createQuery("select o from Order o where o.customer=#{currentContact.customer}");
          
          
           orders = (List<Order>) query.getResultList();
          
          
           }
          }


          • 2. Re: Facotry-session and bean-conversation
            yohann49

            If I remove the Datamodel annotation, my jsf page is empty because in the page I use the factory to display the list of order in a datatable.But their no exception.
            So I must Outject my factory, but the exception appears if I do that.

            What could I do ?

            Yohann

            • 3. Re: Facotry-session and bean-conversation
              yohann49

              I found the solution. I forgot the "return orders".

              @Factory(value="orders", scope = SESSION)
               public List<Order> findOrder(){
              
               Query query;
              
               query = em.createQuery("select o from Order o where o.customer=#{currentContact.customer}");
              
              
               orders = (List<Order>) query.getResultList();
               return orders;
              
               }
              


              Thanks !!!!