org.apache.click.extras.control
Class FieldColumn

java.lang.Object
  extended by org.apache.click.control.Column
      extended by org.apache.click.extras.control.FieldColumn
All Implemented Interfaces:
Serializable

public class FieldColumn
extends Column

Provides a FieldColumn for rendering table data cells.

The FieldColumn class is used to define the table cell data <td> editors. Each FieldColumn should include a Field instance.

If the FieldColumn is contained in a standard Table it will render the all the table column data cells using its single field instance.

If the FieldColumn is contained in a FormTable it will both render the column data cells and process any posted column data values using the field instance. Changes to the tables data objects will be available in the Table rowList property.

Please see the FormTable Javadoc for usage examples.

See Also:
Column, FormTable, Serialized Form

Field Summary
protected  Field field
          The columns field to process and render.
 
Fields inherited from class org.apache.click.control.Column
attributes, autolink, dataClass, dataStyles, decorator, escapeHtml, format, headerClass, headerStyles, headerTitle, maxLength, messageFormat, methodCache, name, renderId, sortable, table, titleProperty, width
 
Constructor Summary
FieldColumn()
          Create a FieldColumn with no name or field defined.
FieldColumn(String name)
          Create a table field column with the given property name.
FieldColumn(String name, Field field)
          Create a table field column with the given property name and field.
FieldColumn(String name, String title)
          Create a table field column with the given property name and header title.
FieldColumn(String name, String title, Field field)
          Create a table field column with the given property name, header title and field.
 
Method Summary
 Field getField()
          Return the column editor field.
protected  void renderTableDataContent(Object row, HtmlStringBuffer buffer, Context context, int rowIndex)
          Render the content within the column table data <td> element.
 void setField(Field field)
          Set the column editor field.
 void setProperty(Object row, String propertyName, Object value)
          Set a row value based on the given property name and value.
 
Methods inherited from class org.apache.click.control.Column
getAttribute, getAttributes, getAutolink, getComparator, getDataClass, getDataStyle, getDataStyles, getDecorator, getEscapeHtml, getFormat, getHeaderClass, getHeaderStyle, getHeaderStyles, getHeaderTitle, getId, getMaxLength, getMessageFormat, getName, getProperty, getProperty, getRenderId, getSortable, getTable, getTitleProperty, getWidth, hasAttributes, hasDataStyles, hasHeaderStyles, renderLink, renderTableData, renderTableHeader, setAttribute, setAutolink, setComparator, setDataClass, setDataStyle, setDecorator, setEscapeHtml, setFormat, setHeaderClass, setHeaderStyle, setHeaderTitle, setMaxLength, setMessageFormat, setName, setRenderId, setSortable, setTable, setTextAlign, setTitleProperty, setVerticalAlign, setWidth
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

field

protected Field field
The columns field to process and render.

Constructor Detail

FieldColumn

public FieldColumn(String name)
Create a table field column with the given property name. The table header title will be set as the capitalized property name.

Parameters:
name - the name of the property to render

FieldColumn

public FieldColumn(String name,
                   Field field)
Create a table field column with the given property name and field.

Parameters:
name - the name of the property to render
field - the field to process and render

FieldColumn

public FieldColumn(String name,
                   String title)
Create a table field column with the given property name and header title.

Parameters:
name - the name of the property to render
title - the column header title to render

FieldColumn

public FieldColumn(String name,
                   String title,
                   Field field)
Create a table field column with the given property name, header title and field.

Parameters:
name - the name of the property to render
title - the column header title to render
field - the field to process and render

FieldColumn

public FieldColumn()
Create a FieldColumn with no name or field defined.

Please note the control's name must be defined before it is valid.

Method Detail

getField

public Field getField()
Return the column editor field.

Returns:
the column editor field

setField

public void setField(Field field)
Set the column editor field.

Parameters:
field - the column editor field

setProperty

public void setProperty(Object row,
                        String propertyName,
                        Object value)
Set a row value based on the given property name and value. The given row can either be a Java Object or a Map instance.

If the row is a Java Object this method uses OGNL to set the value of the row based on the property name. Property names can be specified using a path expression e.g: "person.address.city".

If the row object is a Map this method will attempt to set the map's key/value pair based on the property name and value. The key of the map is matched against the property name. If a key matches the property name, the value will be copied to the map.

Note: you can access the underlying Field using getField().

Parameters:
row - the row object to obtain the property from
propertyName - the name of the property
value - the row object property value
Throws:
RuntimeException - if an error occurred obtaining the property

renderTableDataContent

protected void renderTableDataContent(Object row,
                                      HtmlStringBuffer buffer,
                                      Context context,
                                      int rowIndex)
Render the content within the column table data <td> element. If the FieldColumn has a decorator defined this will be used instead to render the table data cell.

Overrides:
renderTableDataContent in class Column
Parameters:
row - the row object to render
buffer - the string buffer to render to
context - the request context
rowIndex - the index of the current row within the parent table