Webcam Chat QuickBooks Advice international calling cards international phone cards
JavaBeat Java Books Certifications Certifications Kits Articles Tutorials Tips QNA Book Store Interview Questions SCJP 1.5 SCJP 1.6 SCWCD 5.0 SCBCD 5.0 SCEA SCJA Feeds

What are the ways of using standard converters of JSF?

Topic :
Feedback Request New QnA Print Email

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.
  1. 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;}
  2. 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" />

  3. 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>

Topic :
Feedback Request New QnA Print Email

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

JavaBeat Website (2004-2011), India
javabeat | advertise | about us | contact | useful resources
Copyright (2004 - 2011), JavaBeat


Technology Blogs
Technology blogs Technology Blogs
blog log