Andreas Junghans wrote:
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
qooxdoo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Hi,
thank You for Your response. But I have still the trouble with
convertion JSONObject to my Object:
The rcp request is:
{"service":"com.tietoenator.nas.common.ui.qooxdoo.RTOrder","method":"tesObj","id":2,"params":[{"$$initialized":true,"classname":"com.tietoenator.nas.common.ui.qooxdoo.Result","name":"com.tietoenator.nas.common.ui.qooxdoo.Result","basename":"Result","constructor":[Class
com.tietoenator.nas.common.ui.qooxdoo.Result],"message":"some
text","ret":1}],"server_data":null}
my java object Result has defined default constructor, getters/setters
The service method testObj is following:
public void tesObj(Result r) throws RemoteServiceException {
System.out.println(r);
}
The instance of the java object Result is created, but I got the
following error message:
{"error":{"code":500,"class":"java.lang.NoSuchMethodException","message":"java.lang.NoSuchMethodException
: tesObj - Cannot convert org.json.JSONObject to
com.tietoenator.nas.common.ui.qooxdoo.Result","origin"
:1,"origMessage":"tesObj - Cannot convert org.json.JSONObject to
com.tietoenator.nas.common.ui.qooxdoo
.Result"},"id":"1"}
Have You another idea how to solve my trouble, or some working example?
-------------------------------------------------------------------------
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
qooxdoo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel