2.1.6. Create and Register a Custom Converter

To create and register a custom converter it's necessary to go through the following steps:

  • In the Project Explorer view open faces-config.xml and select Tree tab.

Converters

Figure 2.45. Converters


  • Select Converters and click on Add button.

  • On the form type the name of your converter in the Converter-id field and name of the class for converters. After clicking Finish button your custom converter is registered under the entered name.

Add Converter Form

Figure 2.46. Add Converter Form


  • Now you can create "converter" class. In the Converter section you should see your Converter-id and Converter-class. Click on Converter-class to generate the source code.

Generation of Source Code for Converter Class

Figure 2.47. Generation of Source Code for Converter Class


  • A usual wizard for creating a Java class will appear. All needed fields here will be adjusted automatically. Just leave everything without changes and click Finish.

New Java Class Form

Figure 2.48. New Java Class Form


  • To open a converter class click again on Converter-class link in the Converter section. Now you are able to add a business logic of converter in the Java editor.

Converter Class

Figure 2.49. Converter Class