O'Reilly logo

IBM Rational Application Developer V6 Portlet Application Development and Portal Tools by Ryan Wilson, Gianfranco Rutigliano, George Kroner, Belen Gonzalez, Karla Galvan, Cristiano Cesario, Juan R. Rodriguez

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

17.8. Implementing a validator

We want to restrict the second number to odd values. Since there is no standard validator for this, you will need to write your own validator. In addition, you will also need to do the following:

  • Register your validator in the configuration file.

  • Link your validator to the number2 field so it can be checked.

Execute the following steps:

1.
Right-click the itso.jsf.calculator package
a. Select New → Class.
b. Enter OddValidator as name.
c. Click Add for Interfaces.
d. Locate the javax.faces.validator.Validator interface and click OK.
e. Select Inherited abstract methods. Click Finish.
Figure 17-37. New Java class
2.
The skeleton class is generated with this method skeleton:
public void validate(FacesContext ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required