Version 3

    In jsf if we want to get a substring from a string then we can write a converter.

    This converter has two types of methods one returns an object and another one returns a string.

     

     

    To use a converter we need to use the following lines of code into faces config file.

    <!-- Declaring an id for the converter -->

    <converter>

          <converter-id>converterId</converter-id> <-- This is converter id that will be used with component.

          <converter-class>Fully.Qualified.Class.Name.SubstringConverter</converter-class>

    </converter>

     

     

     

    <!---- How to use converter with the defined id -- >

     

    <h:outputText value="#{beanName.property}" converter="converterId" />