Documentation
JSFToolbox

Search 

Contents

  1. Introduction
  2. Getting Started
  3. Developing Web Sites
  4. Using Components
  5. Internationalization
  6. Code View Support
  7. Design View Support
  8. Keyboard Shortcuts
  9. Tag Object Toolbars
  10. JSF Server Behaviors
  11. Property Inspectors
Selected 12. JSF Tag Reference

12. JSF Tag Reference

Contents > JSF Tag Reference > JSF Core Tags

10. JSF Core Tag Reference

Contents > JSF Core Tag Reference > f:converter

f:converter

The Converter tag registers a Converter instance on the component associated with the enclosing tag. It takes one attribute: the converterId that you used to register your converter in your Faces configuration file.

        

The Converter interface is implemented by classes that handle custom conversion of user input into a data type expected by the domain model of your JSF application, and vice versa. For example, you might have a select list of countries that your user can choose from.

        

You could create a custom converter to handle converting the underlying Country objects in your list into strings to display to the user. When the user submits the form, your converter would also handle converting the selected country ID into the appropriate Country object expected by your domain model.

Example:

<h:selectOneMenu value="#{customerBean.customer.address.country}">
  <f:converter converterId="countryConverter"></f:converter>
  <f:selectItems value="#{locationBean.countryList}"></f:selectItems>
</h:selectOneMenu>

HTML Output

<select>
  <option value="1">Canada</option>
  <option value="2">USA</option>
  ... 
</select>

Tag Attributes

converterId String
Required
The value of the converter-id element of the converter tag in your Faces configuration file. The JSF framework will create an instance of your converter class and register it with the parent component.