Thank you.
Both solutions worked. I am not aware of pushing items to {} dynamically. I
thought it should be always static literal like
{"item";"ABC","price":"100.00"}.
Anyway, thank you. It is amazing that people are working in weekends also to
support.
Thanks.
Kanugula.
kanugula wrote:
>
> 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-tp15653619p15654221.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
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel