org.richfaces.model
Class TreeDataModel<T>

java.lang.Object
  extended by javax.faces.model.DataModel
      extended by org.ajax4jsf.model.ExtendedDataModel
          extended by org.richfaces.model.AbstractTreeDataModel
              extended by org.richfaces.model.TreeDataModel<T>
Direct Known Subclasses:
CacheableTreeDataModel, ClassicTreeDataModel, SwingTreeDataModel

public abstract class TreeDataModel<T>
extends AbstractTreeDataModel

That is intended for internal use

Author:
Nick Belaevski - nbelaevski@exadel.com created 16.11.2006

Nested Class Summary
static interface TreeDataModel.MissingNodeHandler<T>
          Interface aimed to handle missing nodes for externally-generated keys.
 
Field Summary
protected  TreeDataModelNodeAdaptor<T> nodeAdaptor
           
 
Fields inherited from class org.richfaces.model.AbstractTreeDataModel
SEPARATOR
 
Constructor Summary
TreeDataModel(java.lang.Class<T> clazz, TreeDataModelNodeAdaptor<T> nodeAdaptor, TreeDataModel.MissingNodeHandler<T> missingNodeHandler)
           
 
Method Summary
 void addNode(java.lang.Object parentRowKey, java.lang.Object newNode, java.lang.Object id)
           
 void addNode(java.lang.Object parentRowKey, TreeNode newNode, java.lang.Object id)
           
protected  void doWalk(javax.faces.context.FacesContext context, DataVisitor dataVisitor, Range range, java.lang.Object rowKey, java.lang.Object argument, boolean last)
           
 java.lang.Object getChildNodeId(java.lang.Object childNode)
          Get node local id in it's parent childs collection
 java.lang.Class<T> getClazz()
           
protected  T getData()
           
 TreeDataModelNodeAdaptor<T> getNodeAdaptor()
           
 java.lang.Object getRowData()
           
 java.lang.Object getRowKey()
           
 TreeNode<T> getTreeNode()
          Get current tree node.
 java.lang.Object getTreeNodeRowKey(java.lang.Object node)
          Get row key for certain tree node object
 java.lang.Object getWrappedData()
           
 boolean isLeaf()
          returns whether this node is leaf
 boolean isRowAvailable()
           
 T locateTreeNode(TreeRowKey rowKey)
           
 T locateTreeNode(TreeRowKey rowKey, boolean allowCreate)
           
 void removeNode(java.lang.Object rowKey)
           
 void setRowKey(java.lang.Object rowKey)
          Instead of simple int for current state selection, this model can use any object for select current data.
 void setWrappedData(java.lang.Object data)
           
 void walk(javax.faces.context.FacesContext context, DataVisitor dataVisitor, Range range, java.lang.Object rowKey, java.lang.Object argument, boolean last)
          walk sub-model having row key argument as its root
 void walkModel(javax.faces.context.FacesContext context, DataVisitor visitor, Range range, java.lang.Object key, java.lang.Object argument, boolean last)
          Walk backing sub-model having row key argument as its root.
 
Methods inherited from class org.richfaces.model.AbstractTreeDataModel
convertToKey, getModelTreeNode, getParentRowKey, getRowCount, getRowIndex, processElement, setRowIndex, walk
 
Methods inherited from class org.ajax4jsf.model.ExtendedDataModel
getSerializableModel
 
Methods inherited from class javax.faces.model.DataModel
addDataModelListener, getDataModelListeners, removeDataModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nodeAdaptor

protected final TreeDataModelNodeAdaptor<T> nodeAdaptor
Constructor Detail

TreeDataModel

public TreeDataModel(java.lang.Class<T> clazz,
                     TreeDataModelNodeAdaptor<T> nodeAdaptor,
                     TreeDataModel.MissingNodeHandler<T> missingNodeHandler)
Method Detail

getClazz

public final java.lang.Class<T> getClazz()

getNodeAdaptor

public final TreeDataModelNodeAdaptor<T> getNodeAdaptor()

getRowKey

public java.lang.Object getRowKey()
Specified by:
getRowKey in class ExtendedDataModel
Returns:
key for selected data or null

setRowKey

public void setRowKey(java.lang.Object rowKey)
Description copied from class: ExtendedDataModel

Instead of simple int for current state selection, this model can use any object for select current data. Implementation depend on model, with any restrictions :

  1. key must be Serializable.
  2. Object.toString() method must return representation compatible with UIComponent.getClientId(javax.faces.context.FacesContext), as far as this string will be appended to clientId of iterator component.

Specified by:
setRowKey in class ExtendedDataModel
Parameters:
rowKey - key for select current data, or null for clear selection.

doWalk

protected void doWalk(javax.faces.context.FacesContext context,
                      DataVisitor dataVisitor,
                      Range range,
                      java.lang.Object rowKey,
                      java.lang.Object argument,
                      boolean last)
               throws java.io.IOException
Throws:
java.io.IOException

walk

public void walk(javax.faces.context.FacesContext context,
                 DataVisitor dataVisitor,
                 Range range,
                 java.lang.Object rowKey,
                 java.lang.Object argument,
                 boolean last)
          throws java.io.IOException
Description copied from class: AbstractTreeDataModel
walk sub-model having row key argument as its root

Specified by:
walk in class AbstractTreeDataModel
Parameters:
context - faces context
dataVisitor - org.ajax4jsf.ajax.repeat.UIDataAdaptor.ComponentVisitor
range - TreeRange to constraint the walk
rowKey - row key to treat as root of sub-model
argument - implementation specific argument
last - boolean flag indicating whether we started our walk from last element
Throws:
java.io.IOException
See Also:
ExtendedDataModel#walk(FacesContext, DataVisitor, Range, Object)}

locateTreeNode

public T locateTreeNode(TreeRowKey rowKey)

locateTreeNode

public T locateTreeNode(TreeRowKey rowKey,
                        boolean allowCreate)

isRowAvailable

public boolean isRowAvailable()
Specified by:
isRowAvailable in class javax.faces.model.DataModel

getRowData

public java.lang.Object getRowData()
Specified by:
getRowData in class javax.faces.model.DataModel

isLeaf

public boolean isLeaf()
Description copied from class: AbstractTreeDataModel
returns whether this node is leaf

Specified by:
isLeaf in class AbstractTreeDataModel
Returns:

walkModel

public void walkModel(javax.faces.context.FacesContext context,
                      DataVisitor visitor,
                      Range range,
                      java.lang.Object key,
                      java.lang.Object argument,
                      boolean last)
               throws java.io.IOException
Description copied from class: AbstractTreeDataModel
Walk backing sub-model having row key argument as its root. If there is no backing model configured, calling this method is equivalent to calling AbstractTreeDataModel.walk(FacesContext, DataVisitor, Range, Object, Object, boolean)

Specified by:
walkModel in class AbstractTreeDataModel
Parameters:
context - faces context
visitor - org.ajax4jsf.ajax.repeat.UIDataAdaptor.ComponentVisitor instance
range - Range to constraint the walk
key - row key to treat as root of sub-model
argument - implementation-specific argument
Throws:
java.io.IOException
See Also:
#walk(FacesContext, DataVisitor, Range, TreeRowKey, Object, boolean)}

getWrappedData

public java.lang.Object getWrappedData()
Specified by:
getWrappedData in class javax.faces.model.DataModel

setWrappedData

public void setWrappedData(java.lang.Object data)
Specified by:
setWrappedData in class javax.faces.model.DataModel

getData

protected T getData()

getTreeNode

public TreeNode<T> getTreeNode()
Description copied from class: AbstractTreeDataModel
Get current tree node. Note: valid only for classical TreeNode based tree data model implementation

Specified by:
getTreeNode in class AbstractTreeDataModel
Returns:
current tree node

getTreeNodeRowKey

public java.lang.Object getTreeNodeRowKey(java.lang.Object node)
Get row key for certain tree node object

Overrides:
getTreeNodeRowKey in class AbstractTreeDataModel
Parameters:
node - to get key for
Returns:
node row key

getChildNodeId

public java.lang.Object getChildNodeId(java.lang.Object childNode)
Get node local id in it's parent childs collection

Overrides:
getChildNodeId in class AbstractTreeDataModel
Parameters:
childNode - node to get identifier for
Returns:
node local identifier

addNode

public void addNode(java.lang.Object parentRowKey,
                    TreeNode newNode,
                    java.lang.Object id)
Overrides:
addNode in class AbstractTreeDataModel

addNode

public void addNode(java.lang.Object parentRowKey,
                    java.lang.Object newNode,
                    java.lang.Object id)
Overrides:
addNode in class AbstractTreeDataModel

removeNode

public void removeNode(java.lang.Object rowKey)
Overrides:
removeNode in class AbstractTreeDataModel


Copyright © 2009. All Rights Reserved.