9 Replies Latest reply on Aug 6, 2008 9:41 AM by ig rek

    rich:tab remoting seam

    ig rek Newbie

      Hi,
      this is my problem
      iI’m trying to recover an object Id via a JavaScript method, and use it in a bean, so I definded a JavaScript method which look like




      customer.js



      function setCurrentCustomer (Id) {
      Seam.Component.getInstance("customer").setId(Id);
      }
      


      customerBean


      @stateful
      @Name("customer")
      public class CustomerBean implements CustomerLocal {
      
      
      private Customer customer;
      
      private Long id;
      
      @Factory(customers")
      ...
       ...
      public void setId(Long id){
      this.id=id
      }
      
      public void idUse{
      Customer customer = (Customer) em.createQuery("select c from Customer c where c.customerId  =:Id")            
                       .setParameter("Id", ^getId()^)
                          .getSingleResult();
      }
      
      }
      
      


      
      @Local
      public interface CustomerLocal {
      
      @WebRemote
      public void setId(Long id);
      }
      


      customer.xhtml


      <script type="text/javascript sr="customer.js" 
      .....
      <s:remote include="customer">
        <div>
             <rich:tabPanel  switchType="client" >
              <c:forEach items="#{customers}" var="cus" varStatus="c">     
                  <rich:tab label="#{cus.name}"  onlabelclick="setId(‘#{cus.id}’)">
                     #{cus.name}                
                  </rich:tab>
              </c:forEach>
             </rich:tabPanel>
         
       </div> 
      
      


      it seams like the get Id return a null value, why? and how can i use this value for my query??

        • 1. Re: rich:tab remoting seam
          Michael Courcy Newbie

          Sorry, I'm new to seam, but would you mean


          <rich:tab label="#{cus.name}"  onlabelclick="setCurrentCustomer(‘#{cus.id}’)">
          



          instead of


          <rich:tab label="#{cus.name}"  onlabelclick="setId(‘#{cus.id}’)">
          



          ?

          • 2. Re: rich:tab remoting seam
            ig rek Newbie

            ig rek wrote on Aug 05, 2008 12:46:


            Hi,
            this is my problem
            iI’m trying to recover an object Id via a JavaScript method, and use it in a bean, so I definded a JavaScript method which look like



            customer.js


            function setId (Id) {
            Seam.Component.getInstance("customer").setId(Id);
            }
            


            customerBean

            @stateful
            @Name("customer")
            public class CustomerBean implements CustomerLocal {
            
            
            private Customer customer;
            
            private Long id;
            
            @Factory(customers")
            ...
             ...
            public void setId(Long id){
            this.id=id
            }
            
            public void idUse{
            Customer customer = (Customer) em.createQuery("select c from Customer c where c.customerId  =:Id")            
                             .setParameter("Id", ^getId()^)
                                .getSingleResult();
            }
            
            }
            
            


            
            @Local
            public interface CustomerLocal {
            
            @WebRemote
            public void setId(Long id);
            }
            


            customer.xhtml

            <script type="text/javascript sr="customer.js" 
            .....
            <s:remote include="customer">
              <div>
                   <rich:tabPanel  switchType="client" >
                    <c:forEach items="#{customers}" var="cus" varStatus="c">     
                        <rich:tab label="#{cus.name}"  onlabelclick="setId(‘#{cus.id}’)">
                           #{cus.name}                
                        </rich:tab>
                    </c:forEach>
                   </rich:tabPanel>
               
             </div> 
            
            


            it seams like the get Id return a null value, why? and how can i use this value for my query??


            Click HELP for text formatting instructions. Then edit this text and check the preview.

            • 3. Re: rich:tab remoting seam
              ig rek Newbie

              i made a mistake (copy, past) ;-), you 're right !!, but it dosen't solve my problem, thanks anyway :-)

              • 4. Re: rich:tab remoting seam
                Michael Courcy Newbie

                Hum...


                And if you follow point to point the exemple in remoting


                http://docs.jboss.com/seam/2.0.3.CR1/reference/en-US/html/remoting.html


                Do you manage to have this one working properly ?


                • 5. Re: rich:tab remoting seam
                  ig rek Newbie

                  my problem, i think has no relation with the fact of remoting.
                  i Try to use a data defined in one methode in anotehrone, it seams obvious that it return a null value.
                  do you have any idea ??

                  • 6. Re: rich:tab remoting seam
                    Joshua Davis Expert

                    Two things come to mind here:



                    1. Maybe I missed it, but the conversation doesn't look like it gets promoted to a long running conversation.  Seam may be creating a new conversation for the Seam remoting call, giving you a fresh SFSB every time.  I've made this mistake quite a few times.  I usually put @Begin(join=true) on the web remote method implementation.

                    2. I have noticed that using Ajax4JSF and Seam Remoting together on the same page causes lost conversations and all kinds of strangeness.  Best to avoid it.



                    Hope that helps.

                    • 7. Re: rich:tab remoting seam
                      Michael Courcy Newbie

                      At least it helps me to understand the conversation process and the place of SFSB in there.


                      Thanks.

                      • 8. Re: rich:tab remoting seam
                        Michael Courcy Newbie

                        Thus one solution instead of promoting to a long conversation, would be to change the default scope of CustomerBean


                        @stateful
                        @Scope(SESSION)
                        @Name("customer")
                        public class CustomerBean{ 
                        ...
                        }
                        



                        • 9. Re: rich:tab remoting seam
                          ig rek Newbie

                          hi guys,
                          thank you very much, it was a great help for me.
                          it works after adding



                          @stateful
                          @Scope(ScopeType.SESSION)
                          @Name("customer")
                          public class CustomerBean{ 
                          ...
                          @Begin(join=true)
                          public void setId(Long id){
                          this.id=id 
                          
                          }





                          you were right, it was a conversation problem.
                          thanks again :-)