From the course: Java EE: JavaServer Faces JSF

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Custom JSF converters

Custom JSF converters

From the course: Java EE: JavaServer Faces JSF

Start my 1-month free trial

Custom JSF converters

- [Instructor] Converting with stock JSF converters is fun and all, but what about when we need to have our user input translated to our custom classes, or objects, on the server side? Or in reverse, we need to translate our custom java objects into something nice for our web app user on the web page? We go custom. JSF allows us to very easily create and configure a custom converter. Let's convert the desserts submitted by our dessert selection radio button, into a dessert object, instead of a long variable that it's saved to right now. Come here, we see right for now that the selectOneRadio is bound to the selectOneRadioSelection field on componentListing, and when we go there, we find that it's a long field. So what we're going to do is instead of binding it to a long field, we'll bind it straight to the selectedDessert field, which is a type dessert. So, we have here a vanilla Java class. Let's make it a converter by implementing the javax.faces to convert the converter interface…

Contents