Say you have an object Employee:
public class Employee { ... @Column( nullable = false ) public String getName() { return mName; } public boolean isManager() { return mManager; } }
You have a requirement to construct both a screen to view an individual employee, and a screen to search for employees. For the latter you would like to reuse the Employee class but display its properties a little differently. For example, your individual employee screen may use JpaInspector/HibernateInspector to pick up on the @Column annotation and mark the name property as 'required'. For your search screen you may not want this.
You have some options:
You could create a second metawidget.xml (perhaps metawidget-search.xml) that does not include JpaInspector/HibernateInspector and use it for your search screen:
<m:metawidget value="#{employee}" config="metawidget-search.xml"/>
You can see an example of this in Section 1.4.7, “Swing AppFramework Example”.
You could add an Inspector like XmlInspector to the end of your CompositeInspector chain and explictly set required="false". This would override the inspection result from JpaInspector/HibernateInspector. Then you could use this in a metawidget-search.xml as described above.
You could add an InspectionResultProcessor like FacesInspectionResultProcessor or JexlInspectionResultProcessor to override the required attribute conditionally based on some Expression Language expression.
You could create a custom annotation and custom Inspector (see Section 2.2.7, “Implementing Your Own Inspector (Java)” and a custom WidgetBuilder that excluded annotated properties (see Section 2.4.9, “Implementing Your Own WidgetBuilder”). Then you could use this in a metawidget-search.xml as described above.
You could create another class EmployeeSearch that mirrors Employee. This would introduce some duplication, but may work better if the search properties are substantially different to the employee properties. For example now isManager could be a Boolean (big 'B') so that you could search for 'is a manager', 'is not a manager' and 'don't care'.