Each object has a
ViewPrototypes
Facet (Figure 4.5) which presents a set
of prototypical
View
objects.
Given the settting:
Object employee = /* ... */; FacetRegistry fr = /* ... */;
the canonical manner in which a new
View 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);