|
Basic JSF Features

|
|
This corresponds to JSF component attribute converter.
One way of implementing this is to specify a method-binding expression that would set a method within the backing bean as the converter for the component. In the alternate, a converter identifier could be designated. (This involves classes that subscribe to converter interface, that are registered with keys in the configuration file. Such keys could then be referenced here.)
Apart from designating a converter as an attribute, they could be in form of components that are nested within other components, in order to depict an associated converter.
There are 2 standard components for converters:
f:converterDateTime
f:converterNumber
Converters could also be registered with their identifier using the f:converter component.
The table below shows dWebSpec standard conversion-types and their correspondent converters on the JSF platform.
| Standard Types | JSF Components | Java Types |
| string (default) | | String |
| byte | f:converterNumber cater to all the integer derived types, by specifying integerOnly = true
The delineation of byte, integer and long types could be approximated with the maxIntegerDigits and
minIntegerDigits settings | byte |
| short | short |
| integer | int |
| long | long |
| float | f:converterNumber cater to all the float derived types, with the absence of specifying integerOnly = true (default is false)
The delineation of float or double types could be approximated with the maxFractionDigits and
minFractionDigits settings | float |
| double | double |
| date | f:convertDateTime | Date |
| boolean | | boolean |
Custom converters could be registered and used on the page with the following tag. The registration aspects is
discussed under the subject of behavior-define descriptor:
f:converter
|
SEAM Enhancements
The conversion enhancements provided by Seam is centered on selection category elements, like radioGroup and select elements.
The typical specification for selection would look like this.
ELEMENT DESCRIPTORS |
id |
caption |
type |
value |
component-id |
conversion-type |
validators |
formatter |
required |
visible |
enabled |
group-id |
scope |
| deptId |
|
select |
{bb.deptId} |
|
string |
|
|
|
|
|
|
|
| deptId |
{bb.depts[].deptName} |
options |
{bb.depts[].deptName} |
|
string |
|
|
|
|
|
|
|
In this specification, a key/value set is specified for options and the selected item is the key. Both the input and the selection are string values; hence there is no need for conversion. This however leads to the violation DRY. Whenever there is need for selection from items from a group of specific object type, the objects must be converted to a suitable object type. On JSF platform, the object type of choice is of the type SelectItem.
The first two Seam enhanced conversion components, essayed to allow more flexibilities in the choice of objects used for options and selections.
| s:convertEntity |
Allows using any entity component for options and selected item. As long as there is a label attribute or suitable toString method, and also as long as there is a primary identifier specified with the @id annotation.
The necessary conversion from a string base web page selection to entity selection would be orchestrated by s:convertEntity component. |
| s:converEnum |
Allows using objects based on Java Enum type for options and selected item. As long as there is a label attribute or suitable toString method.
The necessary conversion from a string base web page selection to entity selection would be orchestrated by s:convertEnum component. |
| s:convertDateTime |
Perform date or time conversions taking into consideration the Seam timezone |
|