com.inmethod.grid.column.editable
Class EditablePropertyColumn<M,I,P>

java.lang.Object
  extended by com.inmethod.grid.column.AbstractColumn<M,I>
      extended by com.inmethod.grid.column.AbstractLightWeightColumn<M,I>
          extended by com.inmethod.grid.column.PropertyColumn<M,I,P>
              extended by com.inmethod.grid.column.editable.EditablePropertyColumn<M,I,P>
All Implemented Interfaces:
IGridColumn<M,I>, Serializable, IClusterable, IDetachable
Direct Known Subclasses:
CheckBoxPropertyColumn, DatePropertyColumn, DropDownChoiceColumn

public class EditablePropertyColumn<M,I,P>
extends PropertyColumn<M,I,P>

Property column that uses a TextFieldPanel as cell component when the item is selected.

Author:
Matej Knopp
See Also:
Serialized Form

Constructor Summary
EditablePropertyColumn(IModel<String> headerModel, String propertyExpression)
          Constructor.
EditablePropertyColumn(IModel<String> headerModel, String propertyExpression, String sortProperty)
          Constructor.
EditablePropertyColumn(String columnId, IModel<String> headerModel, String propertyExpression)
          Constructor.
EditablePropertyColumn(String columnId, IModel<String> headerModel, String propertyExpression, String sortProperty)
          Constructor.
 
Method Summary
protected  void addValidators(FormComponent<P> component)
          Override this method to add validators to the displayed formComponent EX: component.setRequired(true); OR: component.add(new myAwesomeValidator());
 boolean cellClicked(IModel<I> rowModel)
          Allows to override default behavior when a row is clicked.
 String getCellCssClass(IModel<I> rowModel, int rowNum)
          Returns the cell specified by rowModel.
protected  IModel<P> getFieldModel(IModel<I> rowModel)
           
protected  boolean isClickToEdit()
           
 boolean isLightWeight(IModel<I> rowModel)
          Returns whether this column is uses a component for cell in given row (not lightweight) or an IRenderable implementation.
 Component newCell(WebMarkupContainer parent, String componentId, IModel<I> rowModel)
          Creates a new cell component.
protected  EditableCellPanel<M,I,P> newCellPanel(String componentId, IModel<I> rowModel, IModel<P> cellModel)
          creates the actual editable version of the cell
 
Methods inherited from class com.inmethod.grid.column.PropertyColumn
convertToString, getConverter, getLocale, getModelObject, getProperty, getPropertyExpression, isEscapeMarkup, newCell, setEscapeMarkup
 
Methods inherited from class com.inmethod.grid.column.AbstractColumn
detach, 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

EditablePropertyColumn

public EditablePropertyColumn(String columnId,
                              IModel<String> headerModel,
                              String propertyExpression,
                              String sortProperty)
Constructor.

Parameters:
columnId - column identified (must be unique within the grid)
headerModel - model for column header
propertyExpression - property expression used to get the displayed value for row object
sortProperty - optional string that will be returned by ISortState to indicate that the column is being sorted

EditablePropertyColumn

public EditablePropertyColumn(String columnId,
                              IModel<String> headerModel,
                              String propertyExpression)
Constructor.

Parameters:
columnId - column identified (must be unique within the grid)
headerModel - model for column header
propertyExpression - property expression used to get the displayed value for row object

EditablePropertyColumn

public EditablePropertyColumn(IModel<String> headerModel,
                              String propertyExpression,
                              String sortProperty)
Constructor. The column id is omitted in this constructor, because the property expression is used as column id.

Parameters:
headerModel - model for column header
propertyExpression - property expression used to get the displayed value for row object
sortProperty - optional string that will be returned by ISortState to indicate that the column is being sorted

EditablePropertyColumn

public EditablePropertyColumn(IModel<String> headerModel,
                              String propertyExpression)
Constructor. The column id is omitted in this constructor, because the property expression is used as column id.

Parameters:
headerModel - model for column header
propertyExpression - property expression used to get the displayed value for row object
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 AbstractLightWeightColumn<M,I>
Parameters:
rowModel - model for given row
Returns:
true if the cell is lightweight, false otherwise

getFieldModel

protected IModel<P> getFieldModel(IModel<I> rowModel)

newCellPanel

protected EditableCellPanel<M,I,P> newCellPanel(String componentId,
                                                IModel<I> rowModel,
                                                IModel<P> cellModel)
creates the actual editable version of the cell

Parameters:
componentId - The non-null id of this component
rowModel - model for given row
cellModel - model for given cell
Returns:
EditableCellPanel containing a FormComponent

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>
Overrides:
newCell in class AbstractLightWeightColumn<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

addValidators

protected void addValidators(FormComponent<P> component)
Override this method to add validators to the displayed formComponent EX: component.setRequired(true); OR: component.add(new myAwesomeValidator());

Parameters:
component -

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>
Overrides:
getCellCssClass in class AbstractColumn<M,I>
Parameters:
rowModel - model for given row
rowNum - index of row for DataGrid, -1 for TreeGrid
Returns:
cell style class or null

cellClicked

public boolean cellClicked(IModel<I> rowModel)
Description copied from class: AbstractColumn
Allows to override default behavior when a row is clicked. Depending on grid settings the default behavior can select the item. If this method returns true the default behavior will be suppressed.

Specified by:
cellClicked in interface IGridColumn<M,I>
Overrides:
cellClicked in class AbstractColumn<M,I>
Parameters:
rowModel - Model for clicked row
Returns:
true if the default behavior when row is clicked should be supressed, false otherwise.

isClickToEdit

protected boolean isClickToEdit()


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