Search code examples
gwtshared

GWT - What to put in the shared folder?


I'm still unsure on what to put into the shared folder. If I'm doing RPC requests, and sending Pojos from the client to the server and vice versa, do I have to put them into the shared folder (because they are used by both - client and server).

EDIT

Maybe I've used the wrong term but when I said Pojo I actually meant DTO.


Solution

  • You don't have to put the RPC POJOs in a shared folder but if you keep them in the client folder, the server would be dependent on the client package because the Pojos are used both by the client and the server. It's definitely better to have client and server strictly separated, and that's what the shared folder is for.

    The stuff I would put into the shared folder is:

    • RPC requests / responses - I'm using the Command pattern (gwt-dispatch)
    • Data Transfer Objects (DTOs) - lightweight objects used to transfer data
    • Input validators - logic that is shared during client-side and server-side validation
    • Shared configuration