org.apache.tapestry.contrib.table.components
Class TableView

java.lang.Object
  extended by org.apache.tapestry.spec.BaseLocatable
      extended by org.apache.tapestry.AbstractComponent
          extended by org.apache.tapestry.BaseComponent
              extended by org.apache.tapestry.contrib.table.components.TableView
All Implemented Interfaces:
EventListener, ITableModelSource, PageDetachListener, PageRenderListener, IComponent, ILocatable, ILocationHolder, IRender

public abstract class TableView
extends BaseComponent
implements PageDetachListener, PageRenderListener, ITableModelSource

A low level Table component that wraps all other low level Table components. This component carries the ITableModel that is used by the other Table components. Please see the documentation of ITableModel if you need to know more about how a table is represented.

This component also handles the saving of the state of the model using an ITableSessionStateManager to determine what part of the model is to be saved and an ITableSessionStoreManager to determine how to save it.

Upon the beginning of a new request cycle when the table model is first needed, the model is obtained using the following process:

Just before the rendering phase the persistent state of the model is saved in the session. This process occurs in reverse:

Please see the Component Reference for details on how to use this component. [Component Reference]

Version:
$Id: TableView.java 243864 2004-03-31 16:32:43Z tsvetelin $
Author:
mindbridge

Field Summary
 
Fields inherited from interface org.apache.tapestry.contrib.table.model.ITableModelSource
TABLE_MODEL_SOURCE_ATTRIBUTE
 
Constructor Summary
TableView()
          The component constructor.
 
Method Summary
 void fireObservedStateChange()
          Invoked when there is a modification of the table state and it needs to be saved
protected  ITableColumnModel generateTableColumnModel(String strDesc)
          Generate a table column model out of the description string provided.
protected  ITableModel generateTableModel(SimpleTableState objState)
          Generate a table model using the 'source' and 'columns' parameters.
 ITableModel getCachedTableModelValue()
           
abstract  Object getColumns()
           
abstract  IBinding getColumnsBinding()
           
abstract  IComponent getColumnSettingsContainer()
           
 ITableSessionStateManager getDefaultTableSessionStateManager()
          The default session state manager to be used in case no such manager is provided by the corresponding parameter.
abstract  String getInitialSortColumn()
           
abstract  boolean getInitialSortOrder()
           
abstract  IBinding getPageSizeBinding()
           
abstract  Serializable getSessionState()
           
abstract  Object getSource()
           
protected  ITableColumnModel getTableColumnModel()
          Returns the table column model as specified by the 'columns' binding.
 ITableModel getTableModel()
          Returns the tableModel.
abstract  ITableModel getTableModelValue()
           
abstract  ITableSessionStateManager getTableSessionStateManager()
           
abstract  ITableSessionStoreManager getTableSessionStoreManager()
           
protected  Serializable loadSessionState()
          Loads the table state using the SessionStoreManager.
 void pageBeginRender(PageEvent event)
          Ensures that the table state is saved before the render phase begins in case there are modifications for which fireObservedStateChange() has not been invoked.
 void pageDetached(PageEvent objEvent)
          Invokes the component member initializations.
 void pageEndRender(PageEvent objEvent)
          Empty implementation of PageRenderListener.pageEndRender(PageEvent).
protected  void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
          Stores a pointer to this component in the Request Cycle while rendering so that wrapped components have access to it.
 void reset()
          Resets the table by removing any stored table state.
protected  void saveSessionState()
          Saves the table state using the SessionStateManager to determine what to save and the SessionStoreManager to determine where to save it.
abstract  void setSessionState(Serializable sessionState)
           
protected  void storeSessionState(Serializable objState)
          Stores the table state using the SessionStoreManager.
protected  void validateValues()
          Make sure that the values stored in the model are useable and correct.
 
Methods inherited from class org.apache.tapestry.BaseComponent
addOuter, finishLoad
 
Methods inherited from class org.apache.tapestry.AbstractComponent
addAsset, addBody, addComponent, cleanupAfterRender, finishLoad, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, format, format, format, format, formatString, formatString, formatString, formatString, generateAttributes, getAsset, getAssets, getBeans, getBinding, getBindingNames, getBindings, getBody, getBodyCount, getChangeObserver, getComponent, getComponents, getContainer, getExtendedId, getId, getIdPath, getListeners, getMessage, getMessages, getNamespace, getPage, getProperty, getSpecification, getString, prepareForRender, render, renderBody, renderInformalParameters, setBinding, setContainer, setId, setNamespace, setPage, setProperty, setSpecification, toString
 
Methods inherited from class org.apache.tapestry.spec.BaseLocatable
getLocation, setLocation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.tapestry.IComponent
addAsset, addBody, addComponent, finishLoad, getAsset, getAssets, getBinding, getBindingNames, getBindings, getComponent, getComponents, getContainer, getExtendedId, getId, getIdPath, getMessage, getMessages, getNamespace, getPage, getProperty, getSpecification, getString, renderBody, setBinding, setContainer, setId, setNamespace, setPage, setProperty, setSpecification
 
Methods inherited from interface org.apache.tapestry.IRender
render
 
Methods inherited from interface org.apache.tapestry.ILocationHolder
setLocation
 
Methods inherited from interface org.apache.tapestry.ILocatable
getLocation
 

Constructor Detail

TableView

public TableView()
The component constructor. Invokes the component member initializations.

Method Detail

getTableModelValue

public abstract ITableModel getTableModelValue()

getSource

public abstract Object getSource()

getColumns

public abstract Object getColumns()

getColumnsBinding

public abstract IBinding getColumnsBinding()

getPageSizeBinding

public abstract IBinding getPageSizeBinding()

getInitialSortColumn

public abstract String getInitialSortColumn()

getInitialSortOrder

public abstract boolean getInitialSortOrder()

getTableSessionStateManager

public abstract ITableSessionStateManager getTableSessionStateManager()

getTableSessionStoreManager

public abstract ITableSessionStoreManager getTableSessionStoreManager()

getColumnSettingsContainer

public abstract IComponent getColumnSettingsContainer()

getSessionState

public abstract Serializable getSessionState()

setSessionState

public abstract void setSessionState(Serializable sessionState)

pageDetached

public void pageDetached(PageEvent objEvent)
Invokes the component member initializations.

Specified by:
pageDetached in interface PageDetachListener
See Also:
PageDetachListener.pageDetached(PageEvent)

reset

public void reset()
Resets the table by removing any stored table state. This means that the current column to sort on and the current page will be forgotten and all data will be reloaded.


getCachedTableModelValue

public ITableModel getCachedTableModelValue()

getTableModel

public ITableModel getTableModel()
Returns the tableModel.

Specified by:
getTableModel in interface ITableModelSource
Returns:
ITableModel the table model used by the table components

generateTableModel

protected ITableModel generateTableModel(SimpleTableState objState)
Generate a table model using the 'source' and 'columns' parameters.

Returns:
the newly generated table model

getTableColumnModel

protected ITableColumnModel getTableColumnModel()
Returns the table column model as specified by the 'columns' binding. If the value of the 'columns' binding is of a type different than ITableColumnModel, this method makes the appropriate conversion.

Returns:
The table column model as specified by the 'columns' binding

generateTableColumnModel

protected ITableColumnModel generateTableColumnModel(String strDesc)
Generate a table column model out of the description string provided. Entries in the description string are separated by commas. Each column entry is of the format name, name:expression, or name:displayName:expression. An entry prefixed with ! represents a non-sortable column. If the whole description string is prefixed with *, it represents columns to be included in a Form.

Parameters:
strDesc - the description of the column model to be generated
Returns:
a table column model based on the provided description

getDefaultTableSessionStateManager

public ITableSessionStateManager getDefaultTableSessionStateManager()
The default session state manager to be used in case no such manager is provided by the corresponding parameter.

Returns:
the default session state manager

fireObservedStateChange

public void fireObservedStateChange()
Invoked when there is a modification of the table state and it needs to be saved

Specified by:
fireObservedStateChange in interface ITableModelSource
See Also:
ITableModelSource.fireObservedStateChange()

pageBeginRender

public void pageBeginRender(PageEvent event)
Ensures that the table state is saved before the render phase begins in case there are modifications for which fireObservedStateChange() has not been invoked.

Specified by:
pageBeginRender in interface PageRenderListener
See Also:
PageRenderListener.pageBeginRender(org.apache.tapestry.event.PageEvent)

pageEndRender

public void pageEndRender(PageEvent objEvent)
Description copied from class: AbstractComponent
Empty implementation of PageRenderListener.pageEndRender(PageEvent). This allows classes to implement PageRenderListener and only implement the PageRenderListener.pageBeginRender(PageEvent) method.

Specified by:
pageEndRender in interface PageRenderListener
Overrides:
pageEndRender in class AbstractComponent
See Also:
PageRenderListener.pageEndRender(PageEvent)

saveSessionState

protected void saveSessionState()
Saves the table state using the SessionStateManager to determine what to save and the SessionStoreManager to determine where to save it.


loadSessionState

protected Serializable loadSessionState()
Loads the table state using the SessionStoreManager.

Returns:
the stored table state

storeSessionState

protected void storeSessionState(Serializable objState)
Stores the table state using the SessionStoreManager.

Parameters:
objState - the table state to store

validateValues

protected void validateValues()
Make sure that the values stored in the model are useable and correct. The changes made here are not saved.


renderComponent

protected void renderComponent(IMarkupWriter writer,
                               IRequestCycle cycle)
Stores a pointer to this component in the Request Cycle while rendering so that wrapped components have access to it.

Overrides:
renderComponent in class BaseComponent
See Also:
BaseComponent.renderComponent(IMarkupWriter, IRequestCycle)