org.apache.myfaces.trinidad.model

## Class BaseMenuModel

- java.lang.Object
- - javax.faces.model.DataModel
  - - org.apache.myfaces.trinidad.model.CollectionModel
    - - org.apache.myfaces.trinidad.model.TreeModel
      - - org.apache.myfaces.trinidad.model.MenuModel
        - - org.apache.myfaces.trinidad.model.BaseMenuModel

- All Implemented Interfaces:
    LocalRowKeyIndex, RowKeyIndex, TreeLocalRowKeyIndex
  Direct Known Subclasses:
    ViewIdPropertyMenuModel, XMLMenuModel

      public abstract class BaseMenuModel
      extends MenuModel

  A base class which takes a TreeModel. Developers can extend this class and just override the getFocusRowKey() method.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.apache.myfaces.trinidad.model.LocalRowKeyIndex

      `LocalRowKeyIndex.Confidence, LocalRowKeyIndex.LocalCachingStrategy`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `BaseMenuModel()` no-arg constructor needed for managed-bean support.
    `` | `BaseMenuModel(Object modelObject)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `enterContainer()` This Collection changes to reflect the children of the current rowData, and the current rowData changes to be null.
    `void` | `exitContainer()` Pops back up to the parent collection.
    `Object` | `getContainerRowKey(Object childKey)` Gets the rowKey of a given child row's container row.
    `int` | `getRowCount()` Gets the number of values in this collection
    `Object` | `getRowData()` Gets the current value identified by the current index or rowKey.
    `int` | `getRowIndex()` Gets the index of the current value.
    `Object` | `getRowKey()` Gets the rowKey of the current row.
    `Object` | `getWrappedData()`
    `boolean` | `isContainer()` Tests to see if the row identified by getRowData() is a container element.
    `boolean` | `isRowAvailable()` Checks to make sure a value exists for the current index or rowKey.
    `void` | `setRowIndex(int index)` Sets up a value at a particular index to be the current value.
    `void` | `setRowKey(Object key)` Finds the row with the matching key and makes it current
    `void` | `setWrappedData(Object data)`

    - ### Methods inherited from class org.apache.myfaces.trinidad.model.MenuModel

      `getFocusRowKey`

    - ### Methods inherited from class org.apache.myfaces.trinidad.model.TreeModel

      `areRowsLocallyAvailable, areRowsLocallyAvailable, areRowsLocallyAvailable, getAllAncestorContainerRowKeys, getContainerRowKey, getDepth, getDepth, isChildCollectionLocallyAvailable, isChildCollectionLocallyAvailable, isChildCollectionLocallyAvailable, isContainerEmpty`

    - ### Methods inherited from class org.apache.myfaces.trinidad.model.CollectionModel

      `addRowKeyChangeListener, areRowsAvailable, areRowsAvailable, areRowsAvailable, areRowsLocallyAvailable, areRowsLocallyAvailable, areRowsLocallyAvailable, clearCachedRow, clearCachedRow, clearCachedRows, clearCachedRows, clearLocalCache, fireRowKeyChange, getCachingStrategy, getEstimatedRowCount, getEstimatedRowCountConfidence, getRowData, getRowData, getSortCriteria, isRowAvailable, isRowAvailable, isRowLocallyAvailable, isRowLocallyAvailable, isSortable, removeRowKeyChangeListener, setSortCriteria`

    - ### 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`

- - ### Constructor Detail

    - #### BaseMenuModel

          public BaseMenuModel(Object modelObject)

      Parameters:
        `modelObject` - the treeModel to use, this object will be passed to `ModelUtils.toTreeModel(java.lang.Object)`.

    - #### BaseMenuModel

          protected BaseMenuModel()

      no-arg constructor needed for managed-bean support. `setWrappedData(java.lang.Object)` must be called soon after constructing this instance.

  - ### Method Detail

    - #### getContainerRowKey

          public Object getContainerRowKey(Object childKey)

      Description copied from class: `TreeModel`
      Gets the rowKey of a given child row's container row.

           |-Root1 (rowKey="r1", containerRowKey=null)
           |  |-Folder1 (rowKey="r1f1", containerRowKey="r1")
           |  |  |-Node1 (rowKey="r1f1n1", containerRowKey="r1f1")
           |  |  |-Node2 (rowKey="r1f1n2", containerRowKey="r1f1")

      Specified by:
        `getContainerRowKey` in class `TreeModel`
      Parameters:
        `childKey` - the rowKey of the child row.
      Returns:
        the rowKey of the container, or null if the child is a root row.

    - #### enterContainer

          public void enterContainer()

      Description copied from class: `TreeModel`
      This Collection changes to reflect the children of the current rowData, and the current rowData changes to be null. The current rowIndex becomes -1. This method should only be called if `TreeModel.isContainer()` returns true. `DataModel.getRowCount()` can be used to get the number of children.
      Specified by:
        `enterContainer` in class `TreeModel`

    - #### exitContainer

          public void exitContainer()

      Description copied from class: `TreeModel`
      Pops back up to the parent collection. The current rowData becomes the rowData of the parent. This Collection will change to include the children of the new rowData.
      Specified by:
        `exitContainer` in class `TreeModel`

    - #### getRowCount

          public int getRowCount()

      Description copied from interface: `RowKeyIndex`
      Gets the number of values in this collection
      Specified by:
        `getRowCount` in interface `RowKeyIndex`
      Specified by:
        `getRowCount` in class `javax.faces.model.DataModel`
      Returns:
        -1 if the number of values is not known.

    - #### getRowData

          public Object getRowData()

      Description copied from interface: `RowKeyIndex`
      Gets the current value identified by the current index or rowKey.
      Specified by:
        `getRowData` in interface `RowKeyIndex`
      Specified by:
        `getRowData` in class `javax.faces.model.DataModel`
      Returns:
        null if the current value has been cleared.
      See Also:
        `RowKeyIndex.getRowKey()`, `RowKeyIndex.getRowIndex()`

    - #### getRowIndex

          public int getRowIndex()

      Description copied from interface: `RowKeyIndex`
      Gets the index of the current value. The current value is returned by calling {link #getRowData}
      Specified by:
        `getRowIndex` in interface `RowKeyIndex`
      Specified by:
        `getRowIndex` in class `javax.faces.model.DataModel`
      Returns:
        the zero-based index of the current value, or -1 if there is no current value

    - #### getRowKey

          public Object getRowKey()

      Description copied from class: `CollectionModel`
      Gets the rowKey of the current row. rowKeys are safer to use than row indices because rowKeys are unaffected by mutations to this collection. rowKeys should have efficient implementations of `Object.equals(java.lang.Object)` and `Object.hashCode()` as they will be used as keys in hashtables. rowKeys should also be Serializable, so that the application can run under all JSF state-saving schemes.
      Specified by:
        `getRowKey` in interface `RowKeyIndex`
      Specified by:
        `getRowKey` in class `CollectionModel`
      Returns:
        this key should be Serializable and immutable.
      See Also:
        `CollectionModel.setRowKey(java.lang.Object)`

    - #### getWrappedData

          public Object getWrappedData()

      Specified by:
        `getWrappedData` in class `javax.faces.model.DataModel`

    - #### isContainer

          public boolean isContainer()

      Description copied from class: `TreeModel`
      Tests to see if the row identified by getRowData() is a container element. Use `TreeModel.isContainerEmpty()` to see if the current container element actually has children, or is an empty container.
      Specified by:
        `isContainer` in class `TreeModel`
      Returns:
        true if the current element may contain children.

    - #### isRowAvailable

          public boolean isRowAvailable()

      Description copied from interface: `RowKeyIndex`
      Checks to make sure a value exists for the current index or rowKey. This is useful if the number of values in this collection is not known (See `RowKeyIndex.getRowCount()`).
      Specified by:
        `isRowAvailable` in interface `RowKeyIndex`
      Specified by:
        `isRowAvailable` in class `javax.faces.model.DataModel`
      Returns:
        true if a value exists; false otherwise.
      See Also:
        `RowKeyIndex.getRowKey()`, `RowKeyIndex.getRowIndex()`

    - #### setRowIndex

          public void setRowIndex(int index)

      Description copied from interface: `RowKeyIndex`
      Sets up a value at a particular index to be the current value. The current value is returned by calling {link #getRowData}
      Specified by:
        `setRowIndex` in interface `RowKeyIndex`
      Specified by:
        `setRowIndex` in class `javax.faces.model.DataModel`
      Parameters:
        `index` - the zero-based index of the value to make current. Use -1 to clear the current value

    - #### setRowKey

          public void setRowKey(Object key)

      Description copied from class: `CollectionModel`
      Finds the row with the matching key and makes it current
      Specified by:
        `setRowKey` in interface `RowKeyIndex`
      Specified by:
        `setRowKey` in class `CollectionModel`
      Parameters:
        `key` - the rowKey, previously obtained from `CollectionModel.getRowKey()`.

    - #### setWrappedData

          public void setWrappedData(Object data)

      Specified by:
        `setWrappedData` in class `javax.faces.model.DataModel`

Copyright © 2001-2016 The Apache Software Foundation. All Rights Reserved.