Wednesday, February 2, 2011

Metawidget: Defining Business Objects Using Maps (JSF Version)

I thought I'd do a JSF 2 version of my previous blog entry. Doing it in JSF is a litte more difficult to grok, because the all important methods...

metawidget.setToInspect( values );
metawidget.setPath( "person" );

...are obscured behind JSF's standard syntax:

<m:metawidget value="#{...}"/>

There are a number of ways you could unobscure them, but so as not to be confusing I'll just talk about one here. Basically I will wrap the 'toInspect' values and the 'path' type in MyManagedBean so that I can pass them both in a single ValueExpression:

<m:metawidget value="#{myManagedBean}"/>

Regardless, the crucial point - as with the Swing version - is that there's a MapInspector and a MapWidgetProcessor and they operate on different Maps.

You can download the complete project here.

0 comments: