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

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

public 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:

Parameter Type Direction Required Default Description
tableModel ITableModel in yes   The TableModel to be used to render the table. This binding is typically used only once at the beginning and then the component stores the model in the session state.

If you want the Table to read the model every time you can use a session state manager such as NullTableSessionStateManager that will force it to get the TableModel from this binding every time. If you do this, however, you will be responsible for saving the state of the table yourself.

You can also call the reset() method to force the Table to abandon its old model and reload a new one.

tableSessionStateManager ITableSessionStateManager in no FullTableSessionStateManager This is the session state manager that will control what part of the table model will be saved in the session state. It is then used to recreate the table model from using what was saved in the session. By default, the FullTableSessionStateManager is used, which just saves the entire model into the session. This behaviour may not be appropriate when the data is a lot or it is not Serializable.

You can use one of the stock implementations of ITableSessionStateManager to determine the session state behaviour, or you can just define your own.

tableSessionStoreManager ITableSessionStoreManager in no null Determines how the session state (returned by the session state manager) will be saved in the session. If this parameter is null, then the state will be saved as a persistent property. If it is not null, then the methods of the interface will be used to save and load the state.
element String in no "table" The tag that will be used to wrap the inner components. If no binding is given, the tag that will be generated is 'table'. If you would like to place the bounds of the table elsewhere, you can make the element 'span' or another neutral tag and manually define the table.

Version:
$Id: TableView.java,v 1.3 2003/04/21 15:40:01 hlship Exp $
Author:
mindbridge

Fields inherited from interface org.apache.tapestry.contrib.table.model.ITableModelSource
TABLE_MODEL_SOURCE_ATTRIBUTE
 
Constructor Summary
TableView()
           
 
Method Summary
 void fireObservedStateChange()
          Notifies the model source that the model state has changed, and that it should consider saving it.
 String getElement()
          Returns the element.
 IBinding getElementBinding()
          Returns the elementBinding.
 Serializable getSessionState()
          Returns the sessionState.
 ITableModel getTableModel()
          Returns the tableModel.
 IBinding getTableModelBinding()
          Returns the tableModelBinding.
 ITableSessionStateManager getTableSessionStateManager()
           
 IBinding getTableSessionStateManagerBinding()
          Returns the tableSessionStateManagerBinding.
 ITableSessionStoreManager getTableSessionStoreManager()
           
 IBinding getTableSessionStoreManagerBinding()
          Returns the tableSessionStoreManagerBinding.
protected  Serializable loadSessionState()
           
 void pageBeginRender(PageEvent objEvent)
          Invoked before just before the page renders a response.
 void pageDetached(PageEvent objEvent)
          Invoked by the page from its IPage.detach() method.
protected  void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
          Renders the top level components contained by the receiver.
 void reset()
           
protected  void saveSessionState()
           
 void setElementBinding(IBinding elementBinding)
          Sets the elementBinding.
 void setSessionState(Serializable sessionState)
          Sets the sessionState.
 void setTableModelBinding(IBinding tableModelBinding)
          Sets the tableModelBinding.
 void setTableSessionStateManagerBinding(IBinding tableSessionStateManagerBinding)
          Sets the tableSessionStateManagerBinding.
 void setTableSessionStoreManagerBinding(IBinding tableSessionStoreManagerBinding)
          Sets the tableSessionStoreManagerBinding.
protected  void storeSessionState(Serializable objState)
           
 void updateSessionState(Serializable sessionState)
           
 
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, pageEndRender, 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.event.PageRenderListener
pageEndRender
 
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()
Method Detail

pageDetached

public void pageDetached(PageEvent objEvent)
Description copied from interface: PageDetachListener
Invoked by the page from its IPage.detach() method.
Specified by:
pageDetached in interface PageDetachListener
See Also:
PageDetachListener.pageDetached(PageEvent)

reset

public void reset()

getTableModelBinding

public IBinding getTableModelBinding()
Returns the tableModelBinding.
Returns:
IBinding

setTableModelBinding

public void setTableModelBinding(IBinding tableModelBinding)
Sets the tableModelBinding.
Parameters:
tableModelBinding - The tableModelBinding to set

getTableModel

public ITableModel getTableModel()
Returns the tableModel.
Specified by:
getTableModel in interface ITableModelSource
Returns:
ITableModel

fireObservedStateChange

public void fireObservedStateChange()
Description copied from interface: ITableModelSource
Notifies the model source that the model state has changed, and that it should consider saving it.

This method was added to allow using the table within a Block when the pageBeginRender() listener of the implementation will not be called and automatic state storage will therefore be hard to implement.

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

getTableSessionStateManagerBinding

public IBinding getTableSessionStateManagerBinding()
Returns the tableSessionStateManagerBinding.
Returns:
IBinding

setTableSessionStateManagerBinding

public void setTableSessionStateManagerBinding(IBinding tableSessionStateManagerBinding)
Sets the tableSessionStateManagerBinding.
Parameters:
tableSessionStateManagerBinding - The tableSessionStateManagerBinding to set

getTableSessionStateManager

public ITableSessionStateManager getTableSessionStateManager()

getTableSessionStoreManagerBinding

public IBinding getTableSessionStoreManagerBinding()
Returns the tableSessionStoreManagerBinding.
Returns:
IBinding

setTableSessionStoreManagerBinding

public void setTableSessionStoreManagerBinding(IBinding tableSessionStoreManagerBinding)
Sets the tableSessionStoreManagerBinding.
Parameters:
tableSessionStoreManagerBinding - The tableSessionStoreManagerBinding to set

getTableSessionStoreManager

public ITableSessionStoreManager getTableSessionStoreManager()

getSessionState

public Serializable getSessionState()
Returns the sessionState.
Returns:
Object

setSessionState

public void setSessionState(Serializable sessionState)
Sets the sessionState.
Parameters:
sessionState - The sessionState to set

updateSessionState

public void updateSessionState(Serializable sessionState)

loadSessionState

protected Serializable loadSessionState()

saveSessionState

protected void saveSessionState()

storeSessionState

protected void storeSessionState(Serializable objState)

pageBeginRender

public void pageBeginRender(PageEvent objEvent)
Description copied from interface: PageRenderListener
Invoked before just before the page renders a response. This provides listeners with a last chance to initialize themselves for the render. This initialization can include modifying peristent page properties.
Specified by:
pageBeginRender in interface PageRenderListener
See Also:
PageRenderListener.pageBeginRender(PageEvent)

getElementBinding

public IBinding getElementBinding()
Returns the elementBinding.
Returns:
IBinding

setElementBinding

public void setElementBinding(IBinding elementBinding)
Sets the elementBinding.
Parameters:
elementBinding - The elementBinding to set

getElement

public String getElement()
Returns the element.
Returns:
String

renderComponent

protected void renderComponent(IMarkupWriter writer,
                               IRequestCycle cycle)
Description copied from class: BaseComponent
Renders the top level components contained by the receiver.
Overrides:
renderComponent in class BaseComponent
See Also:
BaseComponent.renderComponent(IMarkupWriter, IRequestCycle)