|
Setting different component types for different table columns |
|
Table uses the following concept for usage of different component types in it.There are predefined column classes(types) that perform necessary cell content formatting within the given table column.If you don't set "columnClass" property(in JSP tag or through API) in the given column object instance then the cell content will be rendered as String representation of the data type used in the data model.If you set correct columnClass for the column then default formatting of the cell will be accomplished.Built-in validation for compatability of the type of data in the data model and columnClass is automatically performed.
There are two entities responsible for content rendering in read-only and editable cells :
| • | cell renderer - entity used to draw read-only cells |
| • | cell editor - entity used to draw editable cells |
Table component has the following predefined column classes that you can use in a given column:
| • | com.softaspects.jsf.component.table.ColumnsClass$Percent |
| • | com.softaspects.jsf.component.table.ColumnsClass$Currency |
| • | com.softaspects.jsf.component.table.ColumnsClass$Date |
| • | com.softaspects.jsf.component.table.ColumnsClass$DateTime |
| • | com.softaspects.jsf.component.table.ColumnsClass$Time |
| • | java.sql.Date |
| • | java.sql.Time |
| • | java.lang.Integer |
| • | java.lang.Double |
| • | java.lang.Boolean |
| • | java.lang.Long |
<%!
String PERCENT = "com.softaspects.jsf.component.table.ColumnsClass$Percent";
String CURRENCY = "com.softaspects.jsf.component.table.ColumnsClass$Currency";
String DATE = "com.softaspects.jsf.component.table.ColumnsClass$Date";
String TIME = "com.softaspects.jsf.component.table.ColumnsClass$Time";
String INT = "java.lang.Integer";
String DBL = "java.lang.Double";
String BLN = "java.lang.Boolean";
%>
<table:tableColumn model="tableColumnModel"
columnSelectionAllowed="true"
overwriteExistent="false">
...
<table:column ID="Column6" modelIndex="5" width="100pt" columnClass="<%=DATE %>" />
<table:column ID="Column7" modelIndex="6" width="100pt" columnClass="<%=TIME %>" />
<table:column ID="Column8" modelIndex="7" width="50pt" align="CENTER" columnClass="<%=BLN%>" />
<table:column ID="Column9" modelIndex="8" width="100pt" columnClass="<%=DBL %>" />
</table:columnModel>
If you set correct columnClass for the column and the given column contains editable cells then default cell editor corresponding to columnClass will be automatically used. Also you can substitute the default cell editor for the given columnClass with other predefined cell editor :
<table:column ID="Column8"
modelIndex="7"
width="50pt"
align="CENTER"
columnClass="<%=BLN%>" >
<table:setColumnEditor
editorClass="com.softaspects.framework.galileo.renderers.html.table.columnrenderers.booleans.BooleanListBoxTableCellEditor"/>
</table:column>
You can set predefined cell renderer as the columnClass :
<table:column ID="Column1" modelIndex="0" width="50pt"
hintText="Row counter"
align="CENTER"
valign="TOP"
columnClass="com.softaspects.framework.galileo.renderers.html.table.columnrenderers.string.StringFormatedStringTableCellRenderer"/>
You can find all predefined cell renderers and cell editors in com.softaspects.framework.galileo.renderers.html.table.columnrenderers.* package. Make sure that you don't use abstract classes located there.
Besides, you can easily develop your own cell renderers and editors - see item 9.23 for detail.