The ViewPrototypes Facet

Each object has a Interface org.favabeans.base.ViewPrototypesViewPrototypes Interface org.favabeans.base.FacetFacet (Figure 4.5) which presents a set of prototypical Interface org.favabeans.base.ViewView objects.

Figure 4.5. The Interface org.favabeans.base.ViewPrototypesViewPrototypes Interface org.favabeans.base.FacetFacet.

Given the settting:

Object employee = /* ... */;
FacetRegistry fr = /* ... */;

the canonical manner in which a new Interface org.favabeans.base.ViewView may be created is:

// Get the ViewPrototypes Facet of the domain object

ViewPrototypes fvs = (ViewPrototypes)
  fr.getFacet(employee, new JavaType(ViewPrototypes.class));

// Choose one of the Views available

View someProtoView = fvs.getViewPrototypes()[0]; // say

// Get the Prototype Facet of the chosen View, and create
// a new View using its methods

Prototype s = (Prototype)
  fr.getFacet(someProtoView, new JavaType(Prototype.class));
View newView = (View)s.clonePrimaryObject();

// Tell the newly created View to display the original
// domain object

newView.setModel(employee);