views:

30

answers:

1

Hi All, I have to construct a simple viewer page of a model let us assume Person, where i present a set of criterias to the user to choose from(based on state of persisted models) for e.g i have a dropdown for departments showing all the distinct departments for which Person records are available and once departments are chosen , i wish to present users with the list of all distinct designations (like manager,supervisor ..etc.) available for that group , when all the criteria values are selected and show button pressed is when i actually want to show the data. I am using GWT so i have a mvc implemented at client side itself with a view class and backed by a model class. The model class in this case is a simple aggregate class of Person class , that should contain a collection of Person class. Let us assume that the Person class is heavy ( it contains a CLOB field ) so this aggregate model has to be loaded on stages like first i want to display all available criteria values to the user and finally based on his selection of the set of criterias that will act as key will i actually want to go to the server to fetch the data and finally display. My typical approach is that in my model there has to be collections to represent the individual criteria fields that are to be rendered to the user like department, designation and finally another collection for the fully initialized set of Person models, but problem with that is , is see that data (criteria data) is duplicated at multiple places i.e both inside Person class models and criteria collection field in the aggregate class . Is there a established best-practice/design pattern to solve such kind of problem ?? Or what will be a proper solution to this problem.

Thanks in anticipation.

A: 

The data you describe as criteria could exist as database entities in their own right. Ceratinly it would be an odd system in which there wasn't additional informnation attached to Department, and a similar case could be made for Job (Designation). But you could create those tables anyway, if only to provide foreign keys for data integrity constraints.

With such an approach you could populate the Criteria dropdowns out of the various lightweight tables, and only touch Person once the user has chosen their filters and issued the select.

APC
Thanks for that answer, this was an example scenario but in real scenario where criteria fields are not tables by themselves but are fields in the Person table then how would u approach the problem ??
redzedi