See my comments in line, below ...

> Assuming I've this entity class:
>
> package myapp.entity;
> public class Item {
>      private int id;
>      private String productName;
>      private BigDecimal price;
>
>     // getters and setters
>
> }
>
> This class is packaged in a file called entities.jar and because the price
> attribute which is a BigDecimal I can't send this entity directly to GWT
> client over RPC. Then, I need a DTO to encapsulate the values using data
> types that GWT client can understand. The DTO class would be:
>
> package myapp.client.gwt.dto;
> public class *ItemDTO* {
>      private int id;
>      private String productName;
>      private *Double* price;
>
>     // getters and setters
>
> }
>
> Right?
I think that would be the right approach.  Now your service - on the
server side - might take take class Item, construct a new ItemDTO (you
could have a constructor in ItemDTO which takes an Itemas a parameter
and uses that to construct ItemDTO with the proer atributes).  Make
sure you mark the class itemDTO 'implements Serializable".  When you
return the ItemDTO from your service GWT will marshall and unmarshall
these objects on each side of the transaction, tranparently to you.

> Now my service must load an Item, create the corresponding ItemDTO
> and send it back to GWT client. The client changes it, send it back to ther
> server, the server update the Item instance and save.
The client side should not have to change anything.  It works with
ItemDTO on its side and sends it back to the server side as required.

>
> Thinking about the package and the source files. Could I create a java class
> library with the package *myapp.client.gwt.dto* and use this library in
> classpath for the GWT client and the server?
I don't know why not.

Have a great day!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to