Preserve type of Objects in DWR

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

Preserve type of Objects in DWR

kbansal1991
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Preserve type of Objects in DWR

david@butterdev.com
http://directwebremoting.org/dwr/documentation/server/configuration/dwrxml/converters/bean.html#mappingJavaToJavaScript

On 2015-03-05 07:32, [hidden email] wrote:

> Hi,
>
> I am using DWR (3.0.0 rc3) and spring (4.0) integration for server and
> client interaction. My use case is related to inheritance, where I have
> list of subclass (child class) objects on client side and are sent as
> parameter to API call (server) for processing.
>
> Example:
>
> **JavaScript:**
> var arr = [AB, AB, AB, AC]; // List of child class object
> XServiceAPI.setPrefs(arr, {callback: function});
>
> **API:**
> class XServiceAPI {
>   public setPrefs (List<A> aList, HttpServletRequest req) {
>     // processing
>   }
> }
>
> I have class structure like:
>
> class A { // parent class
>   int a;
>   String b;
>
>   constructor/getter/setters...
> }
>
> class AB extends A { // child class
>   List<String> c;
>
>   constructor/getter/setters...
> }
>
> class AC extends B { // child class
>   String d;
>   List <Integer> e;
>
>   constructor/getter/setters...
> }
>
> Currently, while remote call, objects are converted to "A" type i.e.
> type is not preserved and data specific to subclass is lost.
>
> Is there any other way, by which I can preserve the type and the data
> while sending subclass object to server side???
>
> --kB