Creating a custom converter
When you create a custom converter, this converter will need to run on the server as per the JSF lifecycle.
In this recipe, we will create a custom converter to convert from oracle.jbo.domain.ClobDomain
class to java.lang.String
class and vice versa, which will be represented by the employee's Biography
attribute.
In this recipe, the model has been created for you. You can continue from the previous recipe, or you can grab this project's recipe by cloning the CreatingCustomConverter
application from the Git repository.
Getting ready
In order to create a custom JSF converter, we need to perform the following steps:
Create a class that implements the
javax.faces.convert.Conveter
interface.Implement the following two methods:
getAsObject
andgetAsString
.Register this class as a converter inside the
faces-config.xml
file.Apply the converter on input components.
How to do it…
To know how to create a custom converter, perform the following steps:
Right-click on the
ViewController...