com.inmethod.grid.column
Class WicketColumnAdapter<M,I,S>

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

public class WicketColumnAdapter<M,I,S>
extends AbstractColumn<M,I,S>

Adapter that allows using DataTable columns from wicket extensions in an AbstractGrid.

Note that due to different internal structure of AbstractGrid and DataTable this adapter might not work for every IColumn implementation. Basically if the implementation relies on the parent instance given in ICellPopulator.populateItem(Item, String, IModel) it will probably not work properly with this adapter, as the parent instance this adapter uses is only temporary.

Author:
Matej Knopp
See Also:
Serialized Form

Constructor Summary
WicketColumnAdapter(String columnId, IColumn<I,S> column)
          Constructor
 
Method Summary
 String getCellCssClass(IModel<I> rowModel, int rowNum)
          Returns the cell specified by rowModel.
 S getSortProperty()
          Result of this method determines whether the column is sortable and in case it is, also determines the sort property.
 Component newCell(WebMarkupContainer parent, String componentId, IModel<I> rowModel)
          Creates a new cell component.
 Component newHeader(String componentId)
          Creates a new component for column header.
static
<T,M,I,S> List<IGridColumn<M,I,S>>
wrapColumns(IColumn<I,S>[] columns)
          Returns the specified IColumn array as list of WicketColumnAdapters that can be given to an AbstractGrid.
static
<M,I,S> List<IGridColumn<M,I,S>>
wrapColumns(List<IColumn<I,S>> columns)
          Returns the specified IColumn list as list of WicketColumnAdapters that can be given to an AbstractGrid.
 
Methods inherited from class com.inmethod.grid.column.AbstractColumn
cellClicked, detach, getColSpan, getGrid, getHeaderCssClass, getHeaderModel, getHeaderTooltipModel, getId, getInitialSize, getMaxSize, getMinSize, getSizeUnit, getWrapText, isLightWeight, isReorderable, isResizable, newCell, 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

WicketColumnAdapter

public WicketColumnAdapter(String columnId,
                           IColumn<I,S> column)
Constructor

Parameters:
columnId - column identifier (must be unique within the grid)
column - IColumn implementation
Method Detail

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,S>
Specified by:
newCell in class AbstractColumn<M,I,S>
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

newHeader

public Component newHeader(String componentId)
Creates a new component for column header.

Specified by:
newHeader in interface IGridColumn<M,I,S>
Overrides:
newHeader in class AbstractColumn<M,I,S>
Parameters:
componentId - required id that the component must have
Returns:
Component representing a column header

getCellCssClass

public String getCellCssClass(IModel<I> rowModel,
                              int rowNum)
Returns the cell specified by rowModel. The class is applied to the appropriate <td> element in the grid.

Specified by:
getCellCssClass in interface IGridColumn<M,I,S>
Overrides:
getCellCssClass in class AbstractColumn<M,I,S>
Parameters:
rowModel - model for given row
rowNum - index of row for DataGrid, -1 for TreeGrid
Returns:
cell style class or null

getSortProperty

public S getSortProperty()
Result of this method determines whether the column is sortable and in case it is, also determines the sort property. If the column is sortable and user sorts by it, the sort property can then be obtained through IGridSortState.

Specified by:
getSortProperty in interface IGridColumn<M,I,S>
Overrides:
getSortProperty in class AbstractColumn<M,I,S>
Returns:
sort property or null if the column is not sortable
See Also:
IGridSortState.ISortStateColumn.getPropertyName()

wrapColumns

public static <T,M,I,S> List<IGridColumn<M,I,S>> wrapColumns(IColumn<I,S>[] columns)
Returns the specified IColumn array as list of WicketColumnAdapters that can be given to an AbstractGrid. The column identifiers are generated.

Parameters:
columns - array of IColumns
Returns:
list of IGridColumns

wrapColumns

public static <M,I,S> List<IGridColumn<M,I,S>> wrapColumns(List<IColumn<I,S>> columns)
Returns the specified IColumn list as list of WicketColumnAdapters that can be given to an AbstractGrid. The column identifiers are generated.

Parameters:
columns - list of IColumns
Returns:
list of IGridColumns


Copyright © 2007–2014 inMethod s.r.o.. All rights reserved.