I have been using ext-gwt (gxt) for about a year and I feel your pain!
From what I have learned so far, it seems that there are 3 strategies for transferring beans between the client and server:
Here is an overview of each strategy:
- Create a client pojo / bean that extends the BaseModel for each server-side object bean / pojo / entity bean.
- Share pojo / bean between client and server
- Convert the server side of pojo / beans to json before sending it to the client and then use Javascript (json) objects on the client side.
Of course, there are compromises for everyone.
Strategy # 1 integrates nicely into gxt. You can use gxt built into stores and bindings. This is the strategy that I used in the production application, and it worked, but I found it tedious to duplicate beans on the client and server. Personally, I also found that the extjs (and gxt) storage / binding mechanism can be overly complex and complicated for short cases.
Strategy No. 2:. This is the strategy that I will most likely use in my next gxt project. The downside is that you have to make your own form and mesh binding in gxt on the client. But at the top you can share all your beans / pojos. Here is a brief overview of implementation details:
In the server-side src tree, add the .gwt.xml file to the root package containing the pojo / bean server classes. For example: I created this file named "gwt-models.gwt.xml" in com.daveparoulek.gwt.server.models
<module rename-to='gwt-models'> <inherits name='com.google.gwt.user.User' /> <source path="client" /> </module>
In the above example, the beans are actually located inside com.daveparoulek.gwt.server.models.client.
After you configure this setting, you can configure the gwt client project to include the src code inside com.daveparoulek.gwt.server.models by adding the gwt client project "inherit" project to your gwt.xml file, for example:
<inherits name="com.daveparoulek.gwt.server.models" />
Strategy # 3: After watching a few conversations with google on gwt, this seems to be their preferred way of working with objects on the client side. Although this leads to the creation of a json overlay type for each server side of the pojo / bean. It also doesn't fit perfectly in the gxt world. Click here for a very good introduction to this concept.