Hello,

I am using 0.7.2 RPC Java version for posting the data to the server in
Javabean format, which works great when all the javabean fields are filled
by the user.

Some of the fields can be null on the server side.  In order to make this to
work I need to exclude nullable fields in the javascript map as follows. Can
somebody tell me how to build javascript map object dynamically?

callRpc("calculatePrice",
{item:itemField.getValue(),price:priceField.getValue()});

I tried to build an Array and convert to Map like this, but on the
server-side it is missing double quotes around the key and value.

var myArr = [];
myArr.push("item:"+itemField.getValue());
if (priceField.getValue().length > 0)
myArr.push("price:"+priceField.getValue());

callRpc("calculatePrice", "{"+myArr.join()+"}");

What happens on the server side is missing double quotes around item and ABC
with an error "NoSuchMethodException. Cannot convert java.lang.String to
Order". Server stack when the price is not entered.
Request string:
{"service":"MyRpcService","method":"calculatePrice","id":29,"params":["{item:ABC}"],"server_data":null}



Service:
=====
public void calculatePrice(Order instance) throws RemoteException {
 ///do something
}

Domain:
=====
public class Order {

private String item; //cannot be null
private Double price; //can be null

public void setItem() {
  this.item=item;
}
public String getItem() {
  return item;
}

public void setPrice(
  this.price=price;
}

public Double getPrice() {
  return price;
}

}
I have more fields like that. For simplicity they are excluded.

Since price is nullable, if the user doesn't enter any price, I should
exclude it in the above map. I prefer javabean solution even though there is
a work-around using seperate key array and value array.

Thanks.
Kanugula.


-- 
View this message in context: 
http://www.nabble.com/How-to-convert-Array-to-Map-literal-when-passing-to-RPC-Java-tp15653619p15653619.html
Sent from the qooxdoo-devel mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to