GWT - What to put in the shared folder?

感情迁移 提交于 2019-12-30 07:01:26

问题


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.


回答1:


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



回答2:


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.



来源:https://stackoverflow.com/questions/5664601/gwt-what-to-put-in-the-shared-folder

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!