Class AbstractLightWeightColumn<M,I,S>

java.lang.Object
com.inmethod.grid.column.AbstractColumn<M,I,S>
com.inmethod.grid.column.AbstractLightWeightColumn<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
Direct Known Subclasses:
PropertyColumn

public abstract class AbstractLightWeightColumn<M,I,S> extends AbstractColumn<M,I,S>
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:
  • Constructor Details

    • AbstractLightWeightColumn

      public AbstractLightWeightColumn(String columnId, IModel<String> headerModel, S 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 Details

    • 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,S>
      Overrides:
      isLightWeight in class AbstractColumn<M,I,S>
      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,S>
      Overrides:
      newCell in class AbstractColumn<M,I,S>
      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,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