org.apache.myfaces.custom.crosstable
Class UIColumns

java.lang.Object
  extended by javax.faces.component.UIComponent
      extended by javax.faces.component.UIComponentBase
          extended by javax.faces.component.UIData
              extended by org.apache.myfaces.custom.crosstable.UIColumns
All Implemented Interfaces:
javax.faces.component.NamingContainer, javax.faces.component.StateHolder
Direct Known Subclasses:
AbstractHtmlColumns

public class UIColumns
extends javax.faces.component.UIData

An object which can be a child of a t:dataTable, and inserts a dynamic set of columns into the parent table. The set of columns inserted are defined by a collection returned from a value-binding.

Class org.apache.myfaces.component.html.ext.HtmlDataTable (aka t:dataTable) has special-case code to detect a child of this type, and invoke the necessary methods on this class. This class does not work with other UIData implementations. There is no renderer for this component; the HtmlTableRenderer associated with ext.HtmlDataTable is UIColumns-aware, and implements the necessary logic itself.

This class is actually a UIData itself, which is effectively "merged" with the parent HtmlDataTable. It can't be used as a stand-alone table, however, because it uses the DataModel returned by the "value" value-binding to define the columns, and depends on the parent table's "value" value-binding to define the row DataModel.

The "value" attribute of this class must be a value-binding which returns a DataModel of objects (or a List, Array or ResultSet which automatically gets wrapped in the appropriate DataModel).

In a normal table, each UIColumn child has facets and child components which define that column. In this component, the same child components apply to each column (ie are repeated dataModel.size times). However as the columns are rendered, the current DataModel object (ie the object defining the current column) is stored into a variable whose name is defined by attribute "var". This allows the child components of this component to refer to attributes on those objects to set things like the current column's name. When the objects must be rendered as different components (eg h:outputText or h:outputDate), multiple child components can be used with rendered attributes selecting the appropriate one depending upon the current column object's data.

Version:
$Revision: 659874 $ $Date: 2008-05-24 15:59:15 -0500 (Sat, 24 May 2008) $
Author:
Mathias Broekelmann (latest modification by $Author: lu4242 $)

Field Summary
static String COMPONENT_TYPE
           
 
Fields inherited from class javax.faces.component.UIData
COMPONENT_FAMILY
 
Fields inherited from interface javax.faces.component.NamingContainer
SEPARATOR_CHAR
 
Constructor Summary
UIColumns()
           
 
Method Summary
protected  javax.faces.model.DataModel createDataModel()
          Creates a new DataModel around the current value.
 void encodeTableBegin(javax.faces.context.FacesContext context)
          Called from HtmlDataTable.encodeBegin, ie called once when rendering for the entire table starts.
 void encodeTableEnd(javax.faces.context.FacesContext context)
          Called from HtmlDataTable.encodeEnd, ie called once after rendering for the entire table has completed.
 String getClientId(javax.faces.context.FacesContext context)
           
protected  javax.faces.model.DataModel getDataModel()
          Get a DataModel whose wrapped data contains a collection of objects representing columns.
 int getRowCount()
          Get the number of dynamic columns represented by this instance.
 Object getRowData()
          Get the object representing the current column.
 int getRowIndex()
          Get the currently selected column index.
protected  boolean hasErrorMessages(javax.faces.context.FacesContext context)
           
 boolean isRowAvailable()
          Return true if there are any more columns to process.
 void processDecodes(javax.faces.context.FacesContext context)
          Update the input component (if any) in each dynamic column.
 void processUpdates(javax.faces.context.FacesContext context)
           
 void processValidators(javax.faces.context.FacesContext context)
           
protected  void restoreDescendantComponentStates(Iterator childIterator, Object state)
           
protected  Object saveDescendantComponentStates(Iterator childIterator)
           
protected  void setDataModel(javax.faces.model.DataModel dataModel)
           
 void setRowIndex(int colIndex)
          Set the currently selected column.
 void setValue(Object value)
           
 void setValueBinding(String name, javax.faces.el.ValueBinding binding)
           
 
Methods inherited from class javax.faces.component.UIData
broadcast, encodeBegin, encodeEnd, getFamily, getFirst, getFooter, getHeader, getRows, getValue, getVar, queueEvent, restoreState, saveState, setFirst, setFooter, setHeader, setRows, setVar
 
Methods inherited from class javax.faces.component.UIComponentBase
addFacesListener, decode, encodeChildren, findComponent, getAttributes, getChildCount, getChildren, getFacesContext, getFacesListeners, getFacet, getFacets, getFacetsAndChildren, getId, getParent, getRenderer, getRendererType, getRendersChildren, getValueBinding, isRendered, isTransient, processRestoreState, processSaveState, removeFacesListener, restoreAttachedState, saveAttachedState, setId, setParent, setRendered, setRendererType, setTransient
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPONENT_TYPE

public static final String COMPONENT_TYPE
See Also:
Constant Field Values
Constructor Detail

UIColumns

public UIColumns()
Method Detail

isRowAvailable

public boolean isRowAvailable()
Return true if there are any more columns to process.

Overrides:
isRowAvailable in class javax.faces.component.UIData

getRowCount

public int getRowCount()
Get the number of dynamic columns represented by this instance.

Overrides:
getRowCount in class javax.faces.component.UIData

getRowData

public Object getRowData()
Get the object representing the current column.

Overrides:
getRowData in class javax.faces.component.UIData

getRowIndex

public int getRowIndex()
Get the currently selected column index.

Overrides:
getRowIndex in class javax.faces.component.UIData

setRowIndex

public void setRowIndex(int colIndex)
Set the currently selected column.

Overrides:
setRowIndex in class javax.faces.component.UIData

restoreDescendantComponentStates

protected void restoreDescendantComponentStates(Iterator childIterator,
                                                Object state)

saveDescendantComponentStates

protected Object saveDescendantComponentStates(Iterator childIterator)

setValue

public void setValue(Object value)
Overrides:
setValue in class javax.faces.component.UIData

setValueBinding

public void setValueBinding(String name,
                            javax.faces.el.ValueBinding binding)
Overrides:
setValueBinding in class javax.faces.component.UIData

getDataModel

protected javax.faces.model.DataModel getDataModel()
Get a DataModel whose wrapped data contains a collection of objects representing columns.


setDataModel

protected void setDataModel(javax.faces.model.DataModel dataModel)

createDataModel

protected javax.faces.model.DataModel createDataModel()
Creates a new DataModel around the current value.


processDecodes

public void processDecodes(javax.faces.context.FacesContext context)
Update the input component (if any) in each dynamic column.

Overrides:
processDecodes in class javax.faces.component.UIData
See Also:
UIData.processDecodes(javax.faces.context.FacesContext)

processValidators

public void processValidators(javax.faces.context.FacesContext context)
Overrides:
processValidators in class javax.faces.component.UIData
See Also:
UIData.processValidators(javax.faces.context.FacesContext)

processUpdates

public void processUpdates(javax.faces.context.FacesContext context)
Overrides:
processUpdates in class javax.faces.component.UIData
See Also:
UIData.processUpdates(javax.faces.context.FacesContext)

encodeTableBegin

public void encodeTableBegin(javax.faces.context.FacesContext context)
Called from HtmlDataTable.encodeBegin, ie called once when rendering for the entire table starts.


hasErrorMessages

protected boolean hasErrorMessages(javax.faces.context.FacesContext context)

encodeTableEnd

public void encodeTableEnd(javax.faces.context.FacesContext context)
Called from HtmlDataTable.encodeEnd, ie called once after rendering for the entire table has completed.


getClientId

public String getClientId(javax.faces.context.FacesContext context)
Overrides:
getClientId in class javax.faces.component.UIData


Copyright © 2012 The Apache Software Foundation. All Rights Reserved.