3.2.1: 2012-12-13

net.sf.basedb.clients.web.extensions.list
Class AbstractListColumnBean<I,V>

java.lang.Object
  extended by net.sf.basedb.clients.web.extensions.list.AbstractListColumnBean<I,V>
Type Parameters:
I - The type of items that are listed
V - The type of value that is returned by the getValue() method
All Implemented Interfaces:
ListColumnAction<I,V>, Action
Direct Known Subclasses:
PropertyPathActionFactory.PropertyPathAction

public abstract class AbstractListColumnBean<I,V>
extends Object
implements ListColumnAction<I,V>

A simple bean-like implementation of the ListColumn interface. This class is abstract and subclasses must implement the ListColumnAction.getValue(DbControl, Object) method. The default implementation of the getExportValue(DbControl, Object) simply copies the getValue() result. A subclass that need different values must override the getExportValue() method as well.

Since:
3.2
Author:
Nicklas

Field Summary
private  String clazz
           
private  Enumeration<String,String> enumeration
           
private  boolean exportable
           
private  Formatter<?> exportFormatter
           
private  String exportProperty
           
private  boolean filterable
           
private  String filterProperty
           
private  Formatter<? super V> formatter
           
private  String id
           
private  String property
           
private  boolean sortable
           
private  String sortProperty
           
private  String style
           
private  String title
           
private  String tooltip
           
private  Type valueType
           
 
Constructor Summary
AbstractListColumnBean()
           
 
Method Summary
 String getClazz()
          Optional HTML class attribute that is used to style the column through CSS.
 Enumeration<String,String> getEnumeration()
          Get an enumeration of possible values that can be found in the column.
 Formatter<?> getExportFormatter()
          Get a formatter that converts the exported value to a string that is written to the file.
 String getExportProperty()
          Override the default property when this column is used for exporting.
 Object getExportValue(DbControl dc, I item)
          This implementation simply forward to ListColumnAction.getValue(DbControl, Object).
 String getFilterProperty()
          Override the default property when this column is used for filtering.
 Formatter<? super V> getFormatter()
          Get a formatter that converts the current value to a string that is displayed in the column.
 String getId()
          ID attribute of the column.
 String getProperty()
          The property name for referencing data in the column.
 String getSortProperty()
          Override the default property when this column is used for sorting.
 String getStyle()
          Optional HTML style attribute that is used to style the column through CSS.
 String getTitle()
          The column title.
 String getTooltip()
          An optional tooltip that is displayed when the mouse is over the column header.
 Type getValueType()
          The data type of the values that are referenced by the property.
 boolean isExportable()
          A flag to indicate if it is possible to export this column with the generic table exporter or not.
 boolean isFilterable()
          A flag to indicate if filtering on this column is enabled or not.
 boolean isSortable()
          A flag to indicate if sorting by this column is enabled for not.
 void setClazz(String clazz)
           
 void setEnumeration(Enumeration<String,String> enumeration)
           
 void setExportable(boolean exportable)
           
 void setExportFormatter(Formatter<?> exportFormatter)
           
 void setExportProperty(String exportProperty)
           
 void setFilterable(boolean filterable)
           
 void setFilterProperty(String filterProperty)
           
 void setFormatter(Formatter<? super V> formatter)
           
 void setId(String id)
           
 void setProperty(String property)
           
 void setSortable(boolean sortable)
           
 void setSortProperty(String sortProperty)
           
 void setStyle(String style)
           
 void setTitle(String title)
           
 void setTooltip(String tooltip)
           
 void setValueType(Type valueType)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.basedb.clients.web.extensions.list.ListColumnAction
getValue
 

Field Detail

id

private String id

clazz

private String clazz

style

private String style

title

private String title

tooltip

private String tooltip

property

private String property

valueType

private Type valueType

sortable

private boolean sortable

sortProperty

private String sortProperty

filterable

private boolean filterable

filterProperty

private String filterProperty

exportable

private boolean exportable

exportProperty

private String exportProperty

exportFormatter

private Formatter<?> exportFormatter

enumeration

private Enumeration<String,String> enumeration

formatter

private Formatter<? super V> formatter
Constructor Detail

AbstractListColumnBean

public AbstractListColumnBean()
Method Detail

getId

public String getId()
Description copied from interface: ListColumnAction
ID attribute of the column. This is requried and must be a unique id among all columns in the list.

Specified by:
getId in interface ListColumnAction<I,V>

setId

public void setId(String id)

getClazz

public String getClazz()
Description copied from interface: ListColumnAction
Optional HTML class attribute that is used to style the column through CSS.

Specified by:
getClazz in interface ListColumnAction<I,V>

setClazz

public void setClazz(String clazz)

getStyle

public String getStyle()
Description copied from interface: ListColumnAction
Optional HTML style attribute that is used to style the column through CSS.

Specified by:
getStyle in interface ListColumnAction<I,V>

setStyle

public void setStyle(String style)

getTitle

public String getTitle()
Description copied from interface: ListColumnAction
The column title. Required.

Specified by:
getTitle in interface ListColumnAction<I,V>

setTitle

public void setTitle(String title)

getTooltip

public String getTooltip()
Description copied from interface: ListColumnAction
An optional tooltip that is displayed when the mouse is over the column header.

Specified by:
getTooltip in interface ListColumnAction<I,V>

setTooltip

public void setTooltip(String tooltip)

getProperty

public String getProperty()
Description copied from interface: ListColumnAction
The property name for referencing data in the column. This is optional but is needed to enable filtering, sorting and/or exporting.

Specified by:
getProperty in interface ListColumnAction<I,V>
Returns:
The property or null

setProperty

public void setProperty(String property)

getValueType

public Type getValueType()
Description copied from interface: ListColumnAction
The data type of the values that are referenced by the property. Required if a property has been set.

Specified by:
getValueType in interface ListColumnAction<I,V>
Returns:
The data type of the values

setValueType

public void setValueType(Type valueType)

isSortable

public boolean isSortable()
Description copied from interface: ListColumnAction
A flag to indicate if sorting by this column is enabled for not. The sort uses the default property unless it has been overridden by ListColumnAction.getSortProperty().

Specified by:
isSortable in interface ListColumnAction<I,V>
Returns:
TRUE to enable sorting, FALSE to disable

setSortable

public void setSortable(boolean sortable)

getSortProperty

public String getSortProperty()
Description copied from interface: ListColumnAction
Override the default property when this column is used for sorting.

Specified by:
getSortProperty in interface ListColumnAction<I,V>
Returns:
NULL if the default property should be used for sorting

setSortProperty

public void setSortProperty(String sortProperty)

isFilterable

public boolean isFilterable()
Description copied from interface: ListColumnAction
A flag to indicate if filtering on this column is enabled or not. The filter uses the default property unless it has been overridden by ListColumnAction.getFilterProperty().

Specified by:
isFilterable in interface ListColumnAction<I,V>
Returns:
TRUE to enable filtering, FALSE to disable

setFilterable

public void setFilterable(boolean filterable)

getFilterProperty

public String getFilterProperty()
Description copied from interface: ListColumnAction
Override the default property when this column is used for filtering.

Specified by:
getFilterProperty in interface ListColumnAction<I,V>
Returns:
NULL if the default property should be used for filtering

setFilterProperty

public void setFilterProperty(String filterProperty)

isExportable

public boolean isExportable()
Description copied from interface: ListColumnAction
A flag to indicate if it is possible to export this column with the generic table exporter or not. The export uses the default property unless it has been overridden by ListColumnAction.getExportProperty().

Specified by:
isExportable in interface ListColumnAction<I,V>
Returns:
TRUE to enable exporting, FALSE to disable

setExportable

public void setExportable(boolean exportable)

getExportProperty

public String getExportProperty()
Description copied from interface: ListColumnAction
Override the default property when this column is used for exporting.

Specified by:
getExportProperty in interface ListColumnAction<I,V>
Returns:
NULL if the default property should be used for exporting

setExportProperty

public void setExportProperty(String exportProperty)

getEnumeration

public Enumeration<String,String> getEnumeration()
Description copied from interface: ListColumnAction
Get an enumeration of possible values that can be found in the column. This is used to generate a filter with a drop-down containing checkboxes for each option. If no enumeration is specified, a default filter input field is used.

Specified by:
getEnumeration in interface ListColumnAction<I,V>

setEnumeration

public void setEnumeration(Enumeration<String,String> enumeration)

getFormatter

public Formatter<? super V> getFormatter()
Description copied from interface: ListColumnAction
Get a formatter that converts the current value to a string that is displayed in the column. The string may include HTML that is required for proper display. The Formatter.format(Object) method is called once for every item that is listed in the table.

Specified by:
getFormatter in interface ListColumnAction<I,V>
Returns:
A formatter, or null to simply use Object.toString()

setFormatter

public void setFormatter(Formatter<? super V> formatter)

getExportFormatter

public Formatter<?> getExportFormatter()
Description copied from interface: ListColumnAction
Get a formatter that converts the exported value to a string that is written to the file. The Formatter.format(Object) method is called once for every item that is listed in the table.

Specified by:
getExportFormatter in interface ListColumnAction<I,V>
Returns:
A formatter, or null to simply use Object.toString()

setExportFormatter

public void setExportFormatter(Formatter<?> exportFormatter)

getExportValue

public Object getExportValue(DbControl dc,
                             I item)
This implementation simply forward to ListColumnAction.getValue(DbControl, Object). If the exported value should be different from the regular value the subclass must override this method as well.

Specified by:
getExportValue in interface ListColumnAction<I,V>
Parameters:
dc - An open DbControl than can be used to query the database
item - The current item
Returns:
The value that should be exported

3.2.1: 2012-12-13