开发者

GWT Service serving multiple objects

I am new to GWT and I am creating a web interface to show tabular results from 3 diffe开发者_如何转开发rent queries. Therefore I have 3 different object classes defined. Tutors, Students and ClassSchedules. I have used a tabPanel widget which has the Tutors tab as the default. What I want is the user to be able to click on either tab and view the data for each respective query.

So my question is, do I have to create different services for each tab or can I achieve this by defining one service that handles the 3 objects. Any help will be appreciated.


I would create separate services for each of you data types. This is the simplest and the most natural way to achieve what you want and it has some other benefits:

  • you get data from the server only when it is actually needed on the screen,
  • you can reuse these services in other places in your application easier than one composite service

However, there may be cases when one service would be more suitable, but this depends on the structure of you data, on the amount of your data and how users use your application. Still, I suggest starting with 3 services because it is the simplest and the most natural in this situation. You can always refactor your code later if you notice that there are problems with your approach.


You can create:

  1. Service methods each returning list of concrete class.
  2. Service method returning composite object consisting of 3 lists inside.
  3. Service method returning map of lists - then you can easily insert more lists in result in the future.

1 requires 3 requests to server. 2&3 requires one.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜