How to handle metadata for UI screens representation
Case: There are multiple graphs to be displayed, depending on a few parameters selected by user graph type, its details and other UI related stuff vary a lot, what remains common is data.
Create a UI screen for each type of representation, depending on parameter supplied by the user use a particular screen will be loaded
Pros: Very simple, Client is Dubm, each screen has a datasource which gets populated by data send by the server
Cons: Lot of duplication
Keep metadata, say in XML or DB, about user selection and related UI representation. With help of this metadata prepare a value object containing all information for a graph to be plotted.
Pros: Generic solution, Very flexible
Cons: More coding needed, UI is metadata driven, if UI representation changes alot, this may not be the best approach, Client and server needs to be in contract –how to parse the Metadat, this is client is not that dumb.
What I have used:
I preferred second solution fro following reason:
1. In our team, UI development and Server side development is not segregated, hence having a Smart client is not an issue.
2. Represented metadata in XML and then used JAXB to get Object representation, with help of contract, a single class at client is driving the UI
3. No duplication, all changes are limited to either or all of 1.> Metadata XML, 2.> UI class (fulfilling the contract) or 3.> UI Screen