tags:

views:

645

answers:

3

i need validate multiple field in jsf, but i cann't find better way .

sorry for my bad english.

A: 

What kind of validation do you need?

  • Client side: you must use a Javascript validation framework. For example, this one is a good validation framework using jQuery.
  • Server side: you just need to use <f:validateXXX/> components. For exmaple, <f:validateLength minimum="2" maximum="8"/> will check that the field contains a value that has a size between 2 and 8 characters. Otherwise, it will throw an Exception. Note that there a few validator by default, and you will not be able to validate an email address, or something like that. However, it is really easy to develop your own validator...
  • Server side, using Ajax. This is almost the same thing as the previous type of validation, except that the validation is ajaxified, which means that a request will be sent to the server once the user fills a field, and then validate the field. This is usefull to check on the fly the value. The component library Richfaces offers such features.
romaintaz
A: 

thank you

shxiao
A: 

JSF has validation framework that can be used for simple validations. Like mandatory, length, format etc. In addition it allows you to write custom validators which are invoked for field validations once configured in myfaces file.

Also a bunch of fields can be grouped into "SubForms" which will let you validate several fields in a go. A seamless validation without page being submitted would require Ajax integration. (Richfaces is a good option)

Priyank