« November 27, 2007 | Main | December 22, 2007 »

December 3, 2007 Archives

December 3, 2007

Regular Expression Validation in JSF

When most people look at the list of components in ADF Faces they mostly focus on the visual components - and that's understandable, but if you look closer you'll find that there are also non-visual components included such as several validators.

Here is an example of one useful validator - the regular expression validator.

Let's suppose that you want your JSF field to allow only Numeric values - all you need to do is add to it the ADF Faces provided regular expression validator and then provide the right regex format.
For Example:


<af:inputText label="Label 1" autoSubmit="true">
<af:validateRegExp pattern="[0-9]{1,10}"
noMatchMessageDetail="Only Numbers Please"/>
</af:inputText>
<af:commandButton text="commandButton 1"/>

Now run your page and try entering characters to the field and leaving it.
You'll immediately get an error message with the text you provided (implemented using Javascript).

Just one more thing that ADF Faces give you to make life easier...

About December 2007

This page contains all entries posted to Shay Shmeltzer's Weblog in December 2007. They are listed from oldest to newest.

November 27, 2007 is the previous archive.

December 22, 2007 is the next archive.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type and Oracle