org.apache.myfaces.component.html.ext
Class HtmlDataTableHack

java.lang.Object
  extended by javax.faces.component.UIComponent
      extended by javax.faces.component.UIComponentBase
          extended by javax.faces.component.UIData
              extended by javax.faces.component.html.HtmlDataTable
                  extended by org.apache.myfaces.component.html.ext.HtmlDataTableHack
All Implemented Interfaces:
EventListener, javax.faces.component.behavior.ClientBehaviorHolder, javax.faces.component.NamingContainer, javax.faces.component.PartialStateHolder, javax.faces.component.StateHolder, javax.faces.component.UniqueIdVendor, javax.faces.event.ComponentSystemEventListener, javax.faces.event.FacesListener, javax.faces.event.SystemEventListenerHolder, org.apache.myfaces.custom.ExtendedComponentBase
Direct Known Subclasses:
AbstractHtmlDataList, AbstractHtmlDataTable

public abstract class HtmlDataTableHack
extends javax.faces.component.html.HtmlDataTable
implements org.apache.myfaces.custom.ExtendedComponentBase

Reimplement all UIData functionality to be able to have (protected) access the internal DataModel.

Version:
$Revision: 691856 $ $Date: 2008-09-03 21:40:30 -0500 (miƩ, 03 sep 2008) $
Author:
Manfred Geiler (latest modification by $Author: lu4242 $)

Nested Class Summary
protected static class HtmlDataTableHack.PropertyKeys
           
 
Field Summary
 
Fields inherited from class javax.faces.component.html.HtmlDataTable
COMPONENT_FAMILY, COMPONENT_TYPE
 
Fields inherited from class javax.faces.component.UIComponent
BEANINFO_KEY, bindings, COMPOSITE_COMPONENT_TYPE_KEY, COMPOSITE_FACET_NAME, CURRENT_COMPONENT, CURRENT_COMPOSITE_COMPONENT, FACETS_KEY, VIEW_LOCATION_KEY
 
Fields inherited from interface javax.faces.component.NamingContainer
SEPARATOR_CHAR
 
Constructor Summary
HtmlDataTableHack()
           
 
Method Summary
protected  void checkUpdateModelError(javax.faces.context.FacesContext context)
          This method is used when a custom processUpdates and processValidators is defined, to check if a update model error forces the render response for our data, because _isValidChilds is a private field and is not available on child components that inherits this component class like t:dataList.
 void clearRowStates()
          Remove all preserved row state for the dataTable
protected  javax.faces.model.DataModel createDataModel()
          Creates a new DataModel around the current value.
 void deleteRowStateForRow(int deletedIndex)
          Remove preserved row state for deleted row and adjust row state to reflect deleted row.
 void encodeBegin(javax.faces.context.FacesContext context)
           
 void encodeEnd(javax.faces.context.FacesContext context)
           
 String getClientId(javax.faces.context.FacesContext context)
          Hack since RI does not call getRowIndex()
 String getContainerClientId(javax.faces.context.FacesContext context)
           
protected  javax.faces.model.DataModel getDataModel()
           
 String getDerivedRowKeyPrefix()
          This attribute is used to append an unique prefix when rowKey is not used, to prevent a key match a existing component id (note two different components can't have the same unique id).
protected  String getDerivedSubClientId()
          Return the fragment to be used on the container client id to identify a row.
 int getRowCount()
           
 Object getRowData()
           
 int getRowIndex()
           
 Object getRowKey()
          Used to assign a value expression that identify in a unique way a row.
protected  boolean hasErrorMessages(javax.faces.context.FacesContext context)
           
 boolean isForceId()
          If true, this component will force the use of the specified id when rendering.
 boolean isForceIdIndex()
          If false, this component will not append a '[n]' suffix (where 'n' is the row index) to components that are contained within a "list." This value will be true by default and the value will be ignored if the value of forceId is false (or not specified.)
 boolean isPreserveRowComponentState()
          Indicates whether the state for a component in each row should not be discarded before the datatable is rendered again.
 boolean isPreserveRowStates()
          Indicates whether the state for each row should not be discarded before the datatable is rendered again.
 boolean isRowAvailable()
           
 boolean isRowStatePreserved()
          Indicates whether the state for a component in each row should not be discarded before the datatable is rendered again.
 void markInitialState()
           
 void processUpdates(javax.faces.context.FacesContext context)
           
 void processValidators(javax.faces.context.FacesContext context)
           
protected  void restoreDescendantComponentStates(Iterator<javax.faces.component.UIComponent> childIterator, Object state, boolean restoreChildFacets)
           
protected  void restoreDescendantComponentStates(Object state)
           
protected  void restoreFullDescendantComponentDeltaStates(javax.faces.context.FacesContext facesContext, Iterator<javax.faces.component.UIComponent> childIterator, Map<String,Object> state, Object initialState, boolean restoreChildFacets, String containerClientId)
           
protected  void restoreFullDescendantComponentDeltaStates(javax.faces.context.FacesContext facesContext, Map<String,Object> rowState, Object initialState)
           
protected  void restoreFullDescendantComponentStates(javax.faces.context.FacesContext facesContext, Iterator<javax.faces.component.UIComponent> childIterator, Object initialState, boolean restoreChildFacets)
           
protected  void restoreFullDescendantComponentStates(javax.faces.context.FacesContext facesContext, Object initialState)
           
 void restoreState(javax.faces.context.FacesContext context, Object state)
           
protected  Object saveDescendantComponentStates()
           
protected  Object saveDescendantComponentStates(Iterator<javax.faces.component.UIComponent> childIterator, boolean saveChildFacets)
           
protected  Collection<Object[]> saveDescendantInitialComponentStates(javax.faces.context.FacesContext facesContext)
           
protected  Collection<Object[]> saveDescendantInitialComponentStates(javax.faces.context.FacesContext facesContext, Iterator<javax.faces.component.UIComponent> childIterator, boolean saveChildFacets)
           
protected  Map<String,Object> saveFullDescendantComponentStates(javax.faces.context.FacesContext facesContext)
           
protected  Map<String,Object> saveFullDescendantComponentStates(javax.faces.context.FacesContext facesContext, Map<String,Object> stateMap, Iterator<javax.faces.component.UIComponent> childIterator, boolean saveChildFacets, String containerClientId)
           
 Object saveState(javax.faces.context.FacesContext context)
           
protected  void setDataModel(javax.faces.model.DataModel datamodel)
           
 void setDerivedRowKeyPrefix(String derivedRowKeyPrefix)
           
 void setForceId(boolean forceId)
           
 void setForceIdIndex(boolean forceIdIndex)
           
 void setPreserveRowComponentState(boolean preserveComponentState)
           
 void setPreserveRowStates(boolean preserveRowStates)
           
 void setRowIndex(int rowIndex)
           
 void setRowKey(Object rowKey)
           
 void setRowStatePreserved(boolean preserveComponentState)
           
 void setValue(Object value)
           
 void setValueBinding(String name, javax.faces.el.ValueBinding binding)
           
 void setValueExpression(String name, javax.el.ValueExpression binding)
           
 
Methods inherited from class javax.faces.component.html.HtmlDataTable
addClientBehavior, getBgcolor, getBodyrows, getBorder, getCaptionClass, getCaptionStyle, getCellpadding, getCellspacing, getColumnClasses, getDir, getEventNames, getFamily, getFooterClass, getFrame, getHeaderClass, getLang, getOnclick, getOndblclick, getOnkeydown, getOnkeypress, getOnkeyup, getOnmousedown, getOnmousemove, getOnmouseout, getOnmouseover, getOnmouseup, getRowClasses, getRules, getStyle, getStyleClass, getSummary, getTitle, getWidth, setBgcolor, setBodyrows, setBorder, setCaptionClass, setCaptionStyle, setCellpadding, setCellspacing, setColumnClasses, setDir, setFooterClass, setFrame, setHeaderClass, setLang, setOnclick, setOndblclick, setOnkeydown, setOnkeypress, setOnkeyup, setOnmousedown, setOnmousemove, setOnmouseout, setOnmouseover, setOnmouseup, setRowClasses, setRules, setStyle, setStyleClass, setSummary, setTitle, setWidth
 
Methods inherited from class javax.faces.component.UIData
broadcast, createUniqueId, getFirst, getFooter, getHeader, getRows, getValue, getVar, invokeOnComponent, processDecodes, queueEvent, setFirst, setFooter, setHeader, setRows, setVar, visitTree
 
Methods inherited from class javax.faces.component.UIComponentBase
addFacesListener, clearInitialState, decode, encodeAll, encodeChildren, findComponent, getAttributes, getChildCount, getChildren, getClientBehaviors, getDefaultEventName, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getParent, getRenderer, getRendererType, getRendersChildren, getValueBinding, initialStateMarked, isRendered, isTransient, processRestoreState, processSaveState, removeFacesListener, restoreAttachedState, saveAttachedState, setId, setParent, setRendered, setRendererType, setTransient
 
Methods inherited from class javax.faces.component.UIComponent
getClientId, getCompositeComponentParent, getCurrentComponent, getCurrentCompositeComponent, getListenersForEventClass, getNamingContainer, getResourceBundleMap, getStateHelper, getStateHelper, getValueExpression, isCompositeComponent, isInView, isVisitable, popComponentFromEL, processEvent, pushComponentToEL, setInView, subscribeToEvent, unsubscribeFromEvent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.faces.component.behavior.ClientBehaviorHolder
getClientBehaviors, getDefaultEventName
 

Constructor Detail

HtmlDataTableHack

public HtmlDataTableHack()
Method Detail

isRowAvailable

public boolean isRowAvailable()
Overrides:
isRowAvailable in class javax.faces.component.UIData

getRowCount

public int getRowCount()
Overrides:
getRowCount in class javax.faces.component.UIData

getRowData

public Object getRowData()
Overrides:
getRowData in class javax.faces.component.UIData

getRowIndex

public int getRowIndex()
Overrides:
getRowIndex in class javax.faces.component.UIData

getClientId

public String getClientId(javax.faces.context.FacesContext context)
Hack since RI does not call getRowIndex()

Overrides:
getClientId in class javax.faces.component.UIComponentBase

getContainerClientId

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

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)

checkUpdateModelError

protected void checkUpdateModelError(javax.faces.context.FacesContext context)
This method is used when a custom processUpdates and processValidators is defined, to check if a update model error forces the render response for our data, because _isValidChilds is a private field and is not available on child components that inherits this component class like t:dataList. (TOMAHAWK-1225)


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)

encodeBegin

public void encodeBegin(javax.faces.context.FacesContext context)
                 throws IOException
Overrides:
encodeBegin in class javax.faces.component.UIData
Throws:
IOException
See Also:
UIData.encodeBegin(javax.faces.context.FacesContext)

setPreserveRowStates

public void setPreserveRowStates(boolean preserveRowStates)

isPreserveRowStates

public boolean isPreserveRowStates()
Indicates whether the state for each row should not be discarded before the datatable is rendered again. Setting this to true might be hepful if an input component inside the datatable has no valuebinding and the value entered in there should be displayed again. This will only work reliable if the datamodel of the datatable did not change either by sorting, removing or adding rows. Default: false


isRowStatePreserved

@JSFProperty(literalOnly=true,
             faceletsOnly=true,
             defaultValue="false")
public boolean isRowStatePreserved()
Indicates whether the state for a component in each row should not be discarded before the datatable is rendered again. In tomahawk, this property is the same as t:dataTable preserveRowComponentState This will only work reliable if the datamodel of the datatable did not change either by sorting, removing or adding rows. Default: false

Returns:

setRowStatePreserved

public void setRowStatePreserved(boolean preserveComponentState)

hasErrorMessages

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

encodeEnd

public void encodeEnd(javax.faces.context.FacesContext context)
               throws IOException
Overrides:
encodeEnd in class javax.faces.component.UIData
Throws:
IOException
See Also:
UIComponentBase.encodeEnd(javax.faces.context.FacesContext)

setRowIndex

public void setRowIndex(int rowIndex)
Overrides:
setRowIndex in class javax.faces.component.UIData

restoreDescendantComponentStates

protected void restoreDescendantComponentStates(Object state)

restoreDescendantComponentStates

protected void restoreDescendantComponentStates(Iterator<javax.faces.component.UIComponent> childIterator,
                                                Object state,
                                                boolean restoreChildFacets)

saveDescendantComponentStates

protected Object saveDescendantComponentStates()

saveDescendantComponentStates

protected Object saveDescendantComponentStates(Iterator<javax.faces.component.UIComponent> childIterator,
                                               boolean saveChildFacets)

markInitialState

public void markInitialState()
Specified by:
markInitialState in interface javax.faces.component.PartialStateHolder
Overrides:
markInitialState in class javax.faces.component.UIComponentBase

restoreFullDescendantComponentStates

protected void restoreFullDescendantComponentStates(javax.faces.context.FacesContext facesContext,
                                                    Object initialState)

restoreFullDescendantComponentStates

protected void restoreFullDescendantComponentStates(javax.faces.context.FacesContext facesContext,
                                                    Iterator<javax.faces.component.UIComponent> childIterator,
                                                    Object initialState,
                                                    boolean restoreChildFacets)

saveDescendantInitialComponentStates

protected Collection<Object[]> saveDescendantInitialComponentStates(javax.faces.context.FacesContext facesContext)

saveDescendantInitialComponentStates

protected Collection<Object[]> saveDescendantInitialComponentStates(javax.faces.context.FacesContext facesContext,
                                                                    Iterator<javax.faces.component.UIComponent> childIterator,
                                                                    boolean saveChildFacets)

saveFullDescendantComponentStates

protected Map<String,Object> saveFullDescendantComponentStates(javax.faces.context.FacesContext facesContext)

saveFullDescendantComponentStates

protected Map<String,Object> saveFullDescendantComponentStates(javax.faces.context.FacesContext facesContext,
                                                               Map<String,Object> stateMap,
                                                               Iterator<javax.faces.component.UIComponent> childIterator,
                                                               boolean saveChildFacets,
                                                               String containerClientId)

restoreFullDescendantComponentDeltaStates

protected void restoreFullDescendantComponentDeltaStates(javax.faces.context.FacesContext facesContext,
                                                         Map<String,Object> rowState,
                                                         Object initialState)

restoreFullDescendantComponentDeltaStates

protected void restoreFullDescendantComponentDeltaStates(javax.faces.context.FacesContext facesContext,
                                                         Iterator<javax.faces.component.UIComponent> childIterator,
                                                         Map<String,Object> state,
                                                         Object initialState,
                                                         boolean restoreChildFacets,
                                                         String containerClientId)

restoreState

public void restoreState(javax.faces.context.FacesContext context,
                         Object state)
Specified by:
restoreState in interface javax.faces.component.StateHolder
Overrides:
restoreState in class javax.faces.component.UIComponentBase

saveState

public Object saveState(javax.faces.context.FacesContext context)
Specified by:
saveState in interface javax.faces.component.StateHolder
Overrides:
saveState in class javax.faces.component.UIComponentBase

setValueBinding

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

setValueExpression

public void setValueExpression(String name,
                               javax.el.ValueExpression binding)
Overrides:
setValueExpression in class javax.faces.component.html.HtmlDataTable

setValue

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

getDataModel

protected javax.faces.model.DataModel getDataModel()
Overrides:
getDataModel in class javax.faces.component.UIData

setDataModel

protected void setDataModel(javax.faces.model.DataModel datamodel)
Overrides:
setDataModel in class javax.faces.component.UIData

createDataModel

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


isForceId

public boolean isForceId()
If true, this component will force the use of the specified id when rendering.

Specified by:
isForceId in interface org.apache.myfaces.custom.ExtendedComponentBase
Returns:

setForceId

public void setForceId(boolean forceId)
Specified by:
setForceId in interface org.apache.myfaces.custom.ExtendedComponentBase

isForceIdIndex

public boolean isForceIdIndex()
If false, this component will not append a '[n]' suffix (where 'n' is the row index) to components that are contained within a "list." This value will be true by default and the value will be ignored if the value of forceId is false (or not specified.)

Returns:

setForceIdIndex

public void setForceIdIndex(boolean forceIdIndex)

clearRowStates

public void clearRowStates()
Remove all preserved row state for the dataTable


deleteRowStateForRow

public void deleteRowStateForRow(int deletedIndex)
Remove preserved row state for deleted row and adjust row state to reflect deleted row.

Parameters:
deletedIndex - index of row to delete

isPreserveRowComponentState

@JSFProperty(faceletsOnly=true,
             literalOnly=true)
public boolean isPreserveRowComponentState()
Indicates whether the state for a component in each row should not be discarded before the datatable is rendered again. This property is similar to tomahawk t:dataTable preserveRowStates This will only work reliable if the datamodel of the datatable did not change either by sorting, removing or adding rows. Default: false

Returns:

setPreserveRowComponentState

public void setPreserveRowComponentState(boolean preserveComponentState)

getRowKey

@JSFProperty
public Object getRowKey()
Used to assign a value expression that identify in a unique way a row. This value will be used later instead of rowIndex as a key to be appended to the container client id using getDerivedSubClientId() method.

Returns:

setRowKey

public void setRowKey(Object rowKey)

getDerivedRowKeyPrefix

@JSFProperty(defaultValue="r_id_")
public String getDerivedRowKeyPrefix()
This attribute is used to append an unique prefix when rowKey is not used, to prevent a key match a existing component id (note two different components can't have the same unique id).

Returns:

setDerivedRowKeyPrefix

public void setDerivedRowKeyPrefix(String derivedRowKeyPrefix)

getDerivedSubClientId

protected String getDerivedSubClientId()
Return the fragment to be used on the container client id to identify a row. As a side effect, it will be used to indicate a row component state and a datamodel in nested datatable case.

The returned value must comply with the following rules:

Returns:


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