File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes JSF - Client Side validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "JSF - Client Side validation" Watch "JSF - Client Side validation" New topic

JSF - Client Side validation

dwarakanathan thiru
Ranch Hand

Joined: Oct 14, 2009
Posts: 49
Hi All,
Can any one please tell me how to perform a client side validation in JSF.
Please let me know the different options of client side validation in JSF.

In Struts we have a validation framework, likewise do we have any in JSF?
How about simple java script?

Thanks in advance!!

Dwarak T
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

The basic JSF tagset doesn't support client-side validation, only server-side validation. You can do your own client-side validation using JavaScript in the usual way, since the JSF controls all support the same attributes as their underlying HTML controls, including "onchange", "onblur" and so forth.

It's perfectly possible to create a JSF tagset that automatically generates this javascript as part of the HTML rendering, but I don't know of any tagsets that do that at the moment.

Just remember that client-side validation isn't sufficient to protect the app. You also need server-side validation if you want to avoid problems due to people hacking or because of errors in the client-side validation code.

An IDE is no substitute for an Intelligent Developer.
dwarakanathan thiru
Ranch Hand

Joined: Oct 14, 2009
Posts: 49
Cool!! That was informative. I am going to use the simple javascript in client side and server side.
I agree. Here's the link:
subject: JSF - Client Side validation
It's not a secret anymore!