Defining the Renderer Classes

Two classes are required; one for the "Person Context Panel Widget", the other for the "Horizontal Layout Widget". The skeleton renderer class for the "Person Context Panel Widget" is shown below. The class extends the same base class as the previous widgets, as it too is a view renderer. The class should be created in the component/sample/javasource/sample folder.

Figure 1. The Renderer Class for the "Person Context Panel Widget"
public class PersonContextPanelViewRenderer
       extends AbstractViewRenderer {

  public void render(
      Field field, DocumentFragment fragment,
      RendererContext context, RendererContract contract)
      throws ClientException, DataAccessException {
    // Add the HTML to the "fragment" object here....
  }
}

The skeleton renderer class for the generic "Horizontal Layout Widget" is shown below. The widgets described up to now in this guide have been "view renderer's" based on the AbstractViewRenderer class. The component model provided to each widget was a single Field (the first parameter of its render method). As described in the introduction above, "Horizontal Layout Widget" requires a collection of Field 's. This requires the use of a new base class and in turn, a different signature for the render method. Instead of a Field, a Component is provided to the render method. With the use of a new base class, this renderer class is known as a "component renderer" instead of a "view renderer". The class should be created in the component/sample/javasource/sample folder.

Figure 2. The Renderer Class for the "Horizontal Layout Widget"
public class HorizontalLayoutRenderer
       extends AbstractComponentRenderer {

  public void render(
      Component component, DocumentFragment fragment,
      RendererContext context, RendererContract contract)
      throws ClientException, DataAccessException {
    // Add the HTML to the "fragment" object here....
  }
}