Developing new component types to be shown in table columns

Top  Previous  Next

Table component can be easily extended to adopt any new component type to be shown inside table cells. This may be accomplished following these steps :

 

Develop your new CustomCellRenderer extended from com.softaspects.jsf.renderer.table.cell.DefaultCellRenderer
Override makeRender() method to produce desired HTML content.
Override getTextValue() method to provide necessary value for makeRender() method.
Set new CustomCellRenderer to the given table column through API (com.softaspects.jsf.renderer.table - setColumnClass(int aColumnIndex,java.lang.Class aColumnClass ) method ) or with the help of the corresponding table jsp tag

<table:column ID="Column4" modelIndex="3" width="100pt" columnClass="<%=YOUR_NEW_CELL_RENDERER_TYPE %>" />

 

 

See API doc for detail.

 

Click here to see the source of DefaultCellRenderer that will be useful when developing new CustomCellRenderer.

 

 

For your component types (or standard component types) you can define new editor types. To implement the task you should follow the below steps:

 

Develop your new CustomCellEditor extended from

com.softaspects.jsf.renderer.table.DefaultCellEditor

Set new CustomCellEditor to the given table column through API (com.softaspects.jsf.renderer.table.Column - setCellEditor(int aColumnIndex, java.lang.Class aEditorClass ) method ) or with the help of the corresponding table jsp tag:

<table:column ID="Column5" modelIndex="4">

       <table:setColumnEditor

                       editorClass="com.softaspects.jsf.renderer.table.cell.object.ObjectListBoxTableCellEditor"/>

</table:column>

 

Click here to see the source of DefaultCellEditor that will be useful when developing new CustomCellEditor.

 

DefaultCellRenderer,DefaultCellEditor uses existing base converter for special symbols processing in it's implementation.

For example " ' < > & symbols may cause javascript error if they are used in <input> or <textarea> input fields.

 

 

DefaultCellEditor uses DefaultEditorConverter

DefaultCellRenderer uses DefaultRendererConverter (package com.softaspects.jsf.renderer.table.ext.converter)

 

DefaultEditorConverter - provides correct representation of special characters in edit fields such as INPUT and TEXTAREA.

DefaultRendererConverter - provides correct representation of special characters in table cell.

 

Method String getConvertedValue(Object obj) provides correctly converted value for such special symbols.

 

If you want to use your own converter implementation to process all special needed symbols you should implement Converter interface (com.softaspects.jsf.renderer.table.ext.converter.Converter) and set it in your renderer/editor class with setConverter(Converter myConverter).