From the course: Java EE: JavaServer Faces JSF

Unlock the full course today

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

JSF BigDecimalConverter

JSF BigDecimalConverter

From the course: Java EE: JavaServer Faces JSF

Start my 1-month free trial

JSF BigDecimalConverter

- [Instructor] JSF ships with a good selection of default converters that can help with very straightforward conversion scenarios. With these, we can convert text values from the webpage to Java objects and vice versa, all with very little code. Let's take some converters for a spin. We will first test drive the BigDecimal converter. I've added a BigDecimal field to the InputComponentPageBean to accept moneyInput. Having added the field to our backing bean, I've also added a component to capture the input on the Facelet's page. Here's our inputText for the bigDecimalInput and its bound to the moneyInput field. We also have an outputText box here to display the captured moneyInput. Now, let's configure our BigDecimal converter. So, on the inputText field, we'll set the converter attribute to be the fully qualified class name of the converter, so for the BigDecimal, we will use the javax.faces.BigDecimal. Let's save that. Same for the outputText. Let's configure the converter attribute…

Contents