TOC PREV NEXT INDEX




Understanding Iterative Renderers


Iterative renderers are renderers that iterate over a collection of data and render markup for each data point.

A common example of an iterative renderer is the TableRenderer. It renders a UIData component which can be bound to a model bean that provides the collection of data. The renderer iterates over the collection of data and renders a table row for each element in the collection.

There are a few principles to keep in mind when authoring an iterative renderer.

An iterative renderer will render its own children. It is possible, but more complicated to do otherwise; so it is recommended that you override the method public boolean getRendersChildren() from the abstract class javax.faces.render.Renderer. The overriding method in your iterative renderer should return true:


 
public boolean getRendersChildren() { return true; }
 

 

In order to properly render the ids of the DOM Elements, the iterative renderer must maintain the current index of the data set that is being rendered. This state (the current index) exists in the UIComponent class but will be maintained by the renderer since it knows when rendering of the current data point has completed and it is time to move on to the next data point. Each time the renderer finishes rendering a data point, it increments the data index in the UIComponent class. The index is accessed by the renderer class in order to formulate the ids of the DOM Elements that it is rendering.



Copyright 2005. ICEsoft Technologies, Inc.
http://www.icesoft.com

TOC PREV NEXT INDEX