You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by bu...@apache.org on 2013/08/23 10:09:53 UTC

svn commit: r875790 - in /websites/staging/isis/trunk: cgi-bin/ content/ content/components/viewers/wicket/customizing-the-viewer.html

Author: buildbot
Date: Fri Aug 23 08:09:53 2013
New Revision: 875790

Log:
Staging update by buildbot for isis

Modified:
    websites/staging/isis/trunk/cgi-bin/   (props changed)
    websites/staging/isis/trunk/content/   (props changed)
    websites/staging/isis/trunk/content/components/viewers/wicket/customizing-the-viewer.html

Propchange: websites/staging/isis/trunk/cgi-bin/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Fri Aug 23 08:09:53 2013
@@ -1 +1 @@
-1516718
+1516731

Propchange: websites/staging/isis/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Fri Aug 23 08:09:53 2013
@@ -1 +1 @@
-1516718
+1516731

Modified: websites/staging/isis/trunk/content/components/viewers/wicket/customizing-the-viewer.html
==============================================================================
--- websites/staging/isis/trunk/content/components/viewers/wicket/customizing-the-viewer.html (original)
+++ websites/staging/isis/trunk/content/components/viewers/wicket/customizing-the-viewer.html Fri Aug 23 08:09:53 2013
@@ -328,10 +328,24 @@ bind(String.class)
 <p>The pages generated by Isis' Wicket viewer are built up of numerous elements,
 from fine-grained widgets for property/parameter fields, to much larger components that take responsibility for rendering an entire entity entity, or a collection of entities.  Under the covers these are all implementations of the the Apache Wicket <code>Component</code> API.  The larger components delegate to the smaller, of course.</p>
 
+<h5>How the Wicket viewer selects components</h5>
+
 <p>Components are created using Isis' <code>ComponentFactory</code> interface, which are registered in turn through the <code>ComponentFactoryRegistrar</code> interface.  Every
-component is categorizes by type (the <code>ComponentType</code> enum); Isis uses this information as well as information taken from Isis' metamodel to determine which <code>ComponentFactory</code> to use.  Generally, the first <code>ComponentFactory</code> that can render a component of a certain type is used (the chain of responsibility pattern).</p>
+component is categorizes by type (the <code>ComponentType</code> enum).  Isis uses this to determine which <code>ComponentFactory</code> to use.  For example, the <code>ComponentType.BOOKMARKED_PAGES</code> is used to locate the <code>ComponentFactory</code> that will build the bookmarked pages panel.</p>
+
+<p>In many cases, though, additional information is needed.  For example,  is the type to render a scalar property or parameter.  But there are many different <code>ComponentFactory</code> implementations; one for a string, one for a boolean, one for a date etc.  </p>
+
+<p>Each factory is also handed a model (an implementation of <code>org.apache.wicket.IModel</code>) appropriate to its <code>ComponentType</code>; this holds the data to be rendered.  For example, <code>ComponentType.BOOKMARKED_PAGES</code> is given a <code>BookmarkedPagesModel</code>, while <code>ComponentType.SCALAR_NAME_AND_VALUE</code> factories are provided a model of type of type <code>ScalarModel</code> .   </p>
+
+<p>In some cases there are several factories for a given <code>ComponentType</code>; this is most notably the case for <code>ComponentType.SCALAR_NAME_AND_VALUE</code>.  After doing a first pass selection of candidate factories by <code>ComponentType</code>, each factory is then asked if it <code>appliesTo(Model)</code>.  This is an opportunity for the factory to check the model itself to see if the data within it is of the appropriate type.</p>
+
+<p>Thus, the <code>BooleanPanelFactory</code> checks that the <code>ScalarModel</code> holds a boolean, while the <code>JodaLocalDatePanelFactory</code> checks to see if it holds  <code>org.joda.time.LocalDate</code>.  </p>
+
+<p>There will typically be only one <code>ComponentFactory</code> capable of rendering a particular <code>ComponentType</code>/<code>ScalarModel</code> combination; at any rate, the framework stops as soon as one is found.  (<em>There is one exception to this design, discussed in the next section</em>).</p>
+
+<h5>How to replace a component</h5>
 
-<p>This design makes it quite straightforward to change the rendering of any element of the page.  For example, you might switch out Isis' sliding bookmark panel and replace it with one that presents the bookmarks in some different fashion.</p>
+<p>This design (the <a href="http://en.wikipedia.org/wiki/Chain-of-responsibility_pattern">chain of responsibility</a> design pattern) makes it quite straightforward to change the rendering of any element of the page.  For example, you might switch out Isis' sliding bookmark panel and replace it with one that presents the bookmarks in some different fashion.</p>
 
 <p>First, you need to write a <code>ComponentFactory</code> and corresponding <code>Component</code>.  The recommended approach is to start with the source of the <code>Component</code> you want to switch out.  For example:</p>