« Introduction to ADF Workshop in Israel Next Month | Main | JDeveloper 11g Technology Preview 3 is Out - SOA and WebCenter Included »

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...

TrackBack

Listed below are links to weblogs that reference Regular Expression Validation in JSF:

» Streamline your JSF validation framework from Benny's Blog
If you’ve every used a Validator in JSF, the chance is that you made your own as well. Read on to find out how you can streamline your code and usage of custom validators. Add your own handmade validators, while using minimum code with maximum fl... [Read More]

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)