6 Replies Latest reply on Mar 8, 2007 9:09 PM by enazareno

    Remoting problem: object as param not passed

    lcoetzee

      Hi,

      I am playing around with the Seam remoting. I am playing with the helloworld seam application:

      I am attempting to pass a seam object (JavaBean) from the browser to the backend. When invoking the method with the parameter, the method is called, but the object is not populated with any values.

      In short I have the following:
      1. The Javabean:

      @Name("person")
      public class Person implements Serializable{
      
       Integer id;
       String name;
       String surname;
      //with getters and setters
      }


      2. The method definition in the interface (HelloLocal):
      @WebRemote
       public void setPerson(String value, Person person);
      


      3. The implementation (HelloAction):
      public void setPerson(String value, Person person) {
       System.out.println("Received value: " + value);
      
       System.out.println("Received from xhtml page " + person.getName() + " " + person.getSurname());
      }


      4. My Javascript being called in the xhtml:
       function sayHello() {
       var p = Seam.Component.newInstance("person");
       p.setId(15);
       p.setName("from");
       p.setSurname("sayHello");
       Seam.Component.getInstance("helloAction").setPerson("from sayhello", p);
       }


      When I invoke the sayHello javascript I see the following in the debug window:
      Thu Jan 25 2007 13:44:32 GMT+0200 (SAST): Request packet:
      <envelope><header><context></context></header><body><call component="helloAction" method="setPerson" id="1">
      <params><param><str>dummyvalue</str></param><param><ref id="0"/></param></params><refs><ref id="0"><bean type="person">
      <member name="id"><number>15</number></member>
      <member name="name"><str>from</str></member>
      <member name="surname"><str>sayHello</str></member>
      </bean></ref></refs></call></body></envelope>


      which is the correct values passed to the backend. Unfortunately the person object is not populated, while the string value is sent correctly. The result:
      3:57:37,988 INFO [STDOUT] Received value: from sayhello
      13:57:37,990 INFO [STDOUT] Received from xhtml page null null
      


      Any suggestions as to why I am not able to send an object as paramter to the server? Interestingly enough I am able to send a person object (created on the backend and returned with "public Person getPerson()" ) to the javascript.

      Thanks

      Louis


        • 1. Re: Remoting problem: object as param not passed
          lcoetzee

          Interestingly enough I can make it work when I change my JavaBean into an Entity:

          @Entity //this makes it work !!!!
          @Name("person")
          public class Person implements Serializable{
          ..
          


          results in this:

          15:16:30,024 INFO [STDOUT] Received value: dummyvalue
          15:16:30,024 INFO [STDOUT] Received from xhtml page pietie petoors
          


          and

          Thu Jan 25 2007 14:50:35 GMT+0200 (SAST): Request packet:
          <envelope><header><context></context></header><body><call component="helloAction" method="setPerson" id="0">
          <params><param><str>dummyvalue</str></param><param><ref id="0"/></param></params><refs><ref id="0"><bean type="person">
          <member name="id"><number>25</number></member>
          <member name="name"><str>pietie</str></member>
          <member name="surname"><str>petoors</str></member>
          </bean></ref></refs></call></body></envelope>


          Seems there is some problem with normal POJO's (JavaBeans) which are not Entities.

          L


          • 2. Re: Remoting problem: object as param not passed
            shane.bryzak

            Could you please post this test case to JIRA? It doesn't seem like it would be a big issue to fix.

            • 3. Re: Remoting problem: object as param not passed
              lcoetzee
              • 4. Re: Remoting problem: object as param not passed
                enazareno

                Hi Shane,

                In relation to this, if the JavaBean is not marked as @Entity, only the string is carried, the other properties like Double values are null. Here is my class

                @Name("sendoutFact")
                public class SendoutFact implements Serializable{
                
                 private String agent;
                 private Double principal;
                
                 public Double getPrincipal() {
                 return principal;
                 }
                
                 public void setPrincipal(Double principal) {
                 this.principal = principal;
                 }
                
                 public String getAgent() {
                 return agent;
                 }
                
                 public void setAgent(String agent) {
                 this.agent = agent;
                 }
                }
                


                In the javascript it outputs the Double value as number, but when it reaches the server it is null. However like in this thread, if I mark it as an entity, everything is OK. Have this issue already been solved?

                Regards,

                Elmo






                • 5. Re: Remoting problem: object as param not passed
                  shane.bryzak

                  This should have been fixed already - are you using the latest version of Seam?

                  • 6. Re: Remoting problem: object as param not passed
                    enazareno

                    Hi,

                    The version I'm using is jboss-seam-1.2.0.PATCH1. Is there another update for this one?

                    Regards,

                    Elmo