Hi,

Am 30.07.2007 um 15:41 schrieb VojBarZ:

> I'm trying to send JS object as parameter to RPC method at the java
> side. Communication is OK, but I don't know how to set the type of the
> given object (or how to retype JSONObject to the java object)
>
> If I try the following code, the JSON conversion throws the exception:
>
> public void testObject(MyObject o) throws RemoteServiceException {
>     ......
> }
>
> If i try set type of the parameter to Object, the HashMap is set up.

The RPC implementation tries to convert any JavaScript object to the  
corresponding method parameter type. If this is a custom class (i.e.  
no simple type or string or map), it's treated as a JavaBean. For  
example, let's say you send the object {"foo":"bar", "num":1} and  
your method expects an instance of MyObject. In this case, a new  
instance of MyObject is created. For this to work, MyObject needs to  
have a public default constructor (i.e. a contructor that doesn't  
take any parameters). Next, the RPC implementation looks for setFoo()  
and setNum() methods. If they exist, they are called with the values  
of "foo" and "num" of the JavaScript object.

In short, you can use strings, simple types, maps, and JavaBeans as  
parameter types. However, you can't use classes that don't have a  
public default constructor. For more information, see http:// 
qooxdoo.org/documentation/0.7/rpc

Regards,

   Andreas


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to