3 Replies Latest reply on Aug 15, 2009 1:35 AM by Arbi Sookazian

    seam conversation

    Thiagu Mariappan Novice

      hi every one


      i am little bit confused with seam conversaction,
      this is my samble code,


      @Stateful
      @Name("productsearch")
      public class ProductListAction  implements Serializable,ProductsList
      {
      
      @In(required=false)
      @Out(required=false)
      Product selectedProduct;
      
      @RequestParameter
      Long rowIndex;
      
      @RequestParameter
      Long category;
      
      @Out(required=false)
      List<Product> productsList;
      
      @Begin(join=true)
      public String search()
      {
         productsList=em.createQuery("from products p where p.category=:category")
                      .setParameter("category",category)
                      .getResultList;
         return "/productSearch.xhtml;"
      }
      
      public String select()
      {
         selectedProduct=productsList.get(rowIndex);
         return "/productSpec.xhtml";
      }
      @End
      public String cancel()
      {
         return "/home.xhrml";
      }
      }
      


      my entity Product also in default scope,
      i did not use any scope type.


      i am getting the null pointer exception from select method,
      while select the product from the list.


      because , the list is empty, what is the worng with my code.


      i am expect the productsList should be live untill if i am invoke the cancal method.


      do i need to cahnge the scope type of the productsList to avoid the null pointer exception.
      i need to know which object should be live in between begin and end method invokation.
      either productsearch or productsList.




        • 1. Re: seam conversation
          Arbi Sookazian Master

          without seeing your xhtml or pages.xml, it looks fine to me.  is the search() method being invoked?  if yes, what is the size of the productsList?  By default, SFSB is conversation-scoped, so you're ok there.


          Also, as per JSR220, a SFSB needs to define a method in the local/remote interface which is annotated with @Remove in the implementation class.  I do not see any @Remove in your SFSB above.

          • 2. Re: seam conversation
            Thiagu Mariappan Novice

            thank u for ur reply


            i am invoking the search method from my home page , i am passing the category param from the home page, depends on the param i am gettign the list of products in my productSearch.xhtml page.


            this is my link on home page



            <s:link action="#{productsearch.search}" propagation="begin" value="Cell Phones ">
            <f:param name="category" value="Cell Phones"/>
            </s:link>


            i am forgot to mention the @Remove annotated method in my code.


            @Remove
            @Destroy
            public void stop() {          
            }
            
            



            i mention my local interface ProductsList implemetation in my previous posting.
            i am ok with SFSB is conversation-scoped,
            i need to know what are all the objects productsList ,productsearch and selectedProduct should be live beteen begin and end invokation.




            • 3. Re: seam conversation
              Arbi Sookazian Master

              When you use @Out, Seam outjects to the default scope (unless you specify alternate scope), so in your case it's outjected to conversation scope (which is the default scope for SFSB).  Keep in mind that a LRC needs to be active prior to the outjection.


              Generally speaking, the instance variables for a conversation-scoped component will be available for the duration of the conversation.


              HTH