4 Replies Latest reply on Mar 16, 2008 8:05 AM by Shane Bryzak

    Sending WebRemote object back to server

    Brom bie Newbie

      Hi all,

      I'm wondering if you can create an entity from the browser side using Seam.component and pass it to server side.

      Here's what I have on the client side:

      <s:remote include="fruit,fruitAdmin"/> 
      var newFruit = Seam.Component.newInstance('fruit');
      var fruitAdmin = Seam.Component.getInstance('fruitAdmin');

      I've made sure that both Fruit and FruitAdmin have proper WebRemote annotations, but when the code above was executed, this is the error that I got:

      java.lang.RuntimeException: Error while unmarshalling - property [id] not found in class [test.Fruit]

      The reference doesn't have any mentions about marshalling a javascript object into its java entity counterpart.  Is this not supported yet?


        • 1. Re: Sending WebRemote object back to server
          Shane Bryzak Master

          This should definitely work.  Could you please post the code for the fruit and fruitAdmin components?

          • 2. Re: Sending WebRemote object back to server
            Brom bie Newbie

            I figure out the original issue but got a new one.

            In my code, I had Fruit.java looking like this:

            package test;
            import org.jboss.seam.ScopeType;
            import org.jboss.seam.annotations.Name;
            import org.jboss.seam.annotations.Scope;
            import org.jboss.seam.annotations.remoting.WebRemote;
            public class Fruit {
                 private long fruitId;
                 private String name;
                 public long getId() {
                      return fruitId;
                 public void setId(long id) {
                      this.fruitId = id;
                 public String getName() {
                      return name;
                 public void setName(String name) {
                      this.name = name;

            It looks like Seam was looking for the member variable instead of the bean property through getter/setter.  So it found fruitId, instead of id.  

            I'm not getting the exception once I changed the fruitId to just id.  However, the value is not getting passed in.

            Here's the rest of the code pieces:


            package test;
            import javax.ejb.Local;
            import org.jboss.seam.annotations.remoting.WebRemote;
            public interface FruitAdmin {
                 public void save(Fruit fruit);


            package test;
            import javax.ejb.Stateless;
            import org.jboss.seam.annotations.Logger;
            import org.jboss.seam.annotations.Name;
            import org.jboss.seam.log.Log;
            public class FruitAdminBean implements FruitAdmin {
                 @Logger Log log;
                 public void save(Fruit fruit) {
                      log.info("getting this fruit id: #0, name #1",fruit.getId(),fruit.getName());

            and finally, the xhtml:

            <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
            <ui:composition xmlns="http://www.w3.org/1999/xhtml"
            <ui:define name="body">
            <s:remote include="fruitAdmin,fruit"/> 
            <script type="text/javascript">
            function createNewFruit() {
                 var fruitAdmin = Seam.Component.getInstance('fruitAdmin');
                 var newFruit = Seam.Component.newInstance('fruit');
                 newFruit.name = "mango";
                 newFruit.justNumber = 56778;
                 newFruit.justString = "orange";

            • 3. Re: Sending WebRemote object back to server
              Brom bie Newbie

              Forgot to mention that when ran, the admin bean produces this output:

              INFO  [FruitAdminBean] getting this fruit id: 0, name mango

              I also tried changing from long to Long and got a null instead of 0.

              • 4. Re: Sending WebRemote object back to server
                Shane Bryzak Master

                Could you post the request xml?  You can get this by turning on debug mode in remoting:


                It may also be useful to see the JavaScript stub that is being generated for the fruit component.  Just type the url that s:remote generates directly into your browser.

                Also you don't need all the @WebRemote annotations on the getter/setter methods in your bean, they are unnecessary.