Hi,

we're using a MVC architecture (our own, not Struts or anything) and are wondering about best ways to produce metadata for the view layer (JSP pages).

Many items that need to be displayed have metadata which affects how they should be displayed. For example isEditable and isMandatory. This metadata is the result of business logic rules which apply everywhere and use case -specific rules. It should be given to JSP pages ready, since it is not feasible to think that JSP pages would be embedded with complicated logic for determining whether a field is editable, for example.

Now, there a few issues with this approach. We might think that items which are handed over to JSP page would be something like

class PresentationItem {
 boolean isEditable;
 boolean isMandatory;
 Object payload;
}

The layer on top of the JSP would have to process complicated items like

class DataItemA {
  DataItemB;
  DataItemC;
  Collection dataItemDs;
}

into

PresentationItemA {
   PresentationItemB;
   PresentationItemC;
   Collection presentationItemDs;
}

At a glance this seems a bit complicated. Also, in many cases such metadata is not needed. For example a page will always show some items the same way. In this case the "metadata-processing" -phase seems like useless work, but should be done anyhow for consistency.

Any ideas?