com.inmethod.grid.column
Class AbstractLightWeightColumn<M,I>

java.lang.Object
  extended by com.inmethod.grid.column.AbstractColumn<M,I>
      extended by com.inmethod.grid.column.AbstractLightWeightColumn<M,I>
Type Parameters:
M - grid model object type
I - row/item model object type
All Implemented Interfaces:
IGridColumn<M,I>, Serializable, IClusterable, IDetachable
Direct Known Subclasses:
PropertyColumn

public abstract class AbstractLightWeightColumn<M,I>
extends AbstractColumn<M,I>

Convenience implementation of IGridColumn. This class should be used as base for lightweight columns.

Contains getters and setters for most properties and takes care of the header component. The only method necessary to implement is newCell(IModel).

Author:
Matej Knopp
See Also:
EditablePropertyColumn, Serialized Form

Constructor Summary
AbstractLightWeightColumn(String columnId, IModel<String> headerModel)
          Creates instance with specified column id and header model
AbstractLightWeightColumn(String columnId, IModel<String> headerModel, String sortProperty)
          Creates instance with specified column id, header model and sort property.
 
Method Summary
 boolean isLightWeight(IModel<I> rowModel)
          Returns whether this column is uses a component for cell in given row (not lightweight) or an IRenderable implementation.
abstract  IRenderable<I> newCell(IModel<I> rowModel)
          Creates a new IRenderable instance that is used to render to render the output of cell for given row.
 Component newCell(WebMarkupContainer parent, String componentId, IModel<I> rowModel)
          Creates a new cell component.
 
Methods inherited from class com.inmethod.grid.column.AbstractColumn
cellClicked, detach, getCellCssClass, getColSpan, getGrid, getHeaderCssClass, getHeaderModel, getHeaderTooltipModel, getId, getInitialSize, getMaxSize, getMinSize, getSizeUnit, getSortProperty, getWrapText, isReorderable, isResizable, newHeader, setGrid, setHeaderTooltipModel, setInitialSize, setMaxSize, setMinSize, setReorderable, setResizable, setSizeUnit, setWrapText
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractLightWeightColumn

public AbstractLightWeightColumn(String columnId,
                                 IModel<String> headerModel,
                                 String sortProperty)
Creates instance with specified column id, header model and sort property.

Parameters:
columnId - column identifier - must be unique within the grid
headerModel - model for column title
sortProperty - optional string that will be returned by ISortState to indicate that the column is being sorted

AbstractLightWeightColumn

public AbstractLightWeightColumn(String columnId,
                                 IModel<String> headerModel)
Creates instance with specified column id and header model

Parameters:
columnId - column identifier - must be unique within the grid
headerModel - model for column title
Method Detail

isLightWeight

public boolean isLightWeight(IModel<I> rowModel)
Returns whether this column is uses a component for cell in given row (not lightweight) or an IRenderable implementation. Generally, if the cell is non-interactive (label only), it's better to use an IRenderable implementation, as it has zero memory footprint

Specified by:
isLightWeight in interface IGridColumn<M,I>
Overrides:
isLightWeight in class AbstractColumn<M,I>
Parameters:
rowModel - model for given row
Returns:
true if the cell is lightweight, false otherwise

newCell

public abstract IRenderable<I> newCell(IModel<I> rowModel)
Creates a new IRenderable instance that is used to render to render the output of cell for given row. This method is called for rows that are lightweight ( IGridColumn.isLightWeight(IModel) returns true ).

Specified by:
newCell in interface IGridColumn<M,I>
Overrides:
newCell in class AbstractColumn<M,I>
Parameters:
rowModel - model for given row
Returns:
IRenderable instance

newCell

public Component newCell(WebMarkupContainer parent,
                         String componentId,
                         IModel<I> rowModel)
Creates a new cell component. This method is called for rows that are not lightweight ( IGridColumn.isLightWeight(IModel) returns false ).

Specified by:
newCell in interface IGridColumn<M,I>
Specified by:
newCell in class AbstractColumn<M,I>
Parameters:
parent - Parent component. This is passed in only for convenience, the method implementation is not supposed to add the newly created component to the parent.
componentId - required id of newly created components
rowModel - model for given row
Returns:
new cell component


Copyright © 2007-2012 inMethod s.r.o.. All Rights Reserved.