开发者

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 in开发者_如何学Goto 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.


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


The shared folder must contain only code that needs to be shared both by the client and the server side. Keep in mind that this code must be executable client side, so you don't have access to some of the Java classes.

So basically any POJO or DTO class should be in the shared folder.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜