How to exchange domain objects on Grails with Ext GWT (GXT)?

My application is logically divided into a server that contains my Grails objects and domain controllers; and the client where I have Ext GWT classes that create all the pages of the user interface.

For user interface requests, I use an AJAX call for a controller method that returns, for example, a list of domain objects as a JSON structure.

Following the DRY principle, I would not want to "serialize" the domain data to a JSON string on the server, and then de-serialize it on the client to another structure - I would like to use the Domain object I already have, I do not need to change several places when I add, modify or delete a new field.

Question: is this a good way to go?

If so, how could you make .groovy domain objects accessible on the "client side" of the GWT Java class?

If not, why is it bad and what would you advise instead?

+3
source share
2 answers

There is no good way - you need a Java object that is GWT serializable. The only real solution I see is to write a plugin (or add to the GWT plugin) a way to automatically generate a data transfer object, possibly using annotations in the grails domain object.

A similar method is used to automatically generate RPCAsync interfaces in the gwt plugin - see GwtGrailsPlugin.groovy in the gwt plugin directory, line 133 or so is the beginning.

( , , ) . , , (, !) .

+1

json xml. REST api .

0

Source: https://habr.com/ru/post/1698729/


All Articles