JSF Tip #17 - Packaging your JSF Converter

In the previous blog entry you learned how to write your own converter. Say you want to distribute this converter to others. How can you make sure the JSF runtime knows about the converter without needing to add it to the faces-config.xml of the web application.

As described in the previous blog entry you need to register the converter in a faces-config.xml. To make it a redistributable converter, put the faces-confg.xml in the META-INF directory. The contents of the JAR file would be similar to the one below.


    /META-INF/faces-config.xml
    /color/ColorConverter.class
        

And then to use you can just add that JAR file to any web application by putting it into the WEB-INF/lib directory.

Posted October 5, 2012

Up