-
1. Re: Sending WebRemote object back to server
shane.bryzak Mar 15, 2008 11:58 PM (in response to brombie.wanch.akewan.com)This should definitely work. Could you please post the code for the fruit and fruitAdmin components?
-
2. Re: Sending WebRemote object back to server
brombie.wanch.akewan.com Mar 16, 2008 2:32 AM (in response to brombie.wanch.akewan.com)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; @Name("fruit") @Scope(ScopeType.EVENT) public class Fruit { private long fruitId; private String name; @WebRemote public long getId() { return fruitId; } @WebRemote public void setId(long id) { this.fruitId = id; } @WebRemote public String getName() { return name; } @WebRemote 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:
FruitAdmin:
package test; import javax.ejb.Local; import org.jboss.seam.annotations.remoting.WebRemote; @Local public interface FruitAdmin { @WebRemote public void save(Fruit fruit); }
FruitAdminBean:
package test; import javax.ejb.Stateless; import org.jboss.seam.annotations.Logger; import org.jboss.seam.annotations.Name; import org.jboss.seam.log.Log; @Stateless @Name("fruitAdmin") 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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:s="http://jboss.com/products/seam/taglib" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:rich="http://richfaces.org/rich" template="/layout/template.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.id=1234; newFruit.name = "mango"; newFruit.justNumber = 56778; newFruit.justString = "orange"; fruitAdmin.save(newFruit); } createNewFruit(); </script> </ui:define> </ui:composition>
-
3. Re: Sending WebRemote object back to server
brombie.wanch.akewan.com Mar 16, 2008 2:35 AM (in response to brombie.wanch.akewan.com)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 Mar 16, 2008 8:05 AM (in response to brombie.wanch.akewan.com)Could you post the request xml? You can get this by turning on debug mode in remoting:
Seam.Remoting.setDebug(true)
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.