Converting collections of mixed types

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Converting collections of mixed types

ramzi.abbyad
Hi there,

We are using DWR3-RC2. I'm a little stuck on something.  Let's say
write a remoted function that accepts an argument of type Map<String,
Object>, but on the javascript side we are passing in an object with
Javascript strings, and Dates. Is there any way to convert these
values to Java Strings and Dates in the inbound parameters?

It seems like this should be possible given that the type information
is available on the serverside.

Thanks for your help!  

Regards,
Ramzi
Reply | Threaded
Open this post in threaded view
|

Re: Converting collections of mixed types

Mike Wilson
Administrator
Right, that's a feature that has been discussed a few times but currently
isn't in standard DWR. You could write your own converter to handle it.
The thing you're talking about really is more like classic JSON where you
mix and match different data types in a dynamically types structure. DWR's
approach is focused more to be type-safe and rely on the Java typing, and we
also usually avoid allowing Object in public interfaces as that could in
theory map to any type (with security implications etc).

But as said above, you could try out writing your own converter.

(BTW, you should be running DWR3 build #587 per my latest reply to your
other thread ;-)

Best regards
Mike

r.abbyad wrote:

> Hi there,
>
> We are using DWR3-RC2. I'm a little stuck on
> something.  Let's say
> write a remoted function that accepts an argument of type Map<String,
> Object>, but on the javascript side we are passing in an object with
> Javascript strings, and Dates. Is there any way to
> convert these
> values to Java Strings and Dates in the inbound parameters?
>
> It seems like this should be possible given that the type information
> is available on the serverside.
>
> Thanks for your help!  
>
> Regards,
> Ramzi