What are the ways of using standard converters of JSF?
|
|
|
|
|
Standard converters other than the two which have their own tags (DateTimeConverter
and NumberConverter) can be used in one of the following three ways. The first
one converts the model value of the component and the other two ways convert the component's local value.
- Bind UI Component to Backing Bean Property :
Make sure that the component has its value bound to a backing bean property of the same type as the converter.
For example, converting component data to a float number requires
binding the component to the property like :
Float value = 0.0;
public Float getValue(){ return value;}
public void setValue(Float value) {this.value = value;}
|
- Use “converter” attribute on the UI Component :
Using the converter attribute of the component tag. Just specify the
fully qualified class name or ID of the converter in the converter attribute. If the
component is not bound to a bean property then this option can be
used. For
example,
<h:inputText converter="javax.faces.Integer" />
|
- Use <f:converter> Tag with ConverterId Attribute :
Using converter tag within the component tag and refer the converter
by specifying the ID of the converter in the convertId attribute. For example:
<h:inputText value="#{Bean.Value}" />
<f:converter converterId="Float" />
</h:inputText> |
|
|
|
|
|
|
|
All
api
java
java 6.0
java 7.0
jdbc
jsp
servlet
ejb
jndi
jms
ejb 3.0
j2ee
jee 5.0
jee 6.0
jsf
struts
spring
Hibernate
ajax
JBoss Seam
netbeans
eclipse
ant
xml
maven
dojo
junit
javafx
j2me
log4j
ESB
JBoss
Apache
Quartz
scjp
mysql
oracle
gwt
openjpa
jmx
yui
google-guice
android
JBoss
scwcd 5.0
scjp 1.5
scjp 1.6
scja
scbcd 5.0
|