Tuesday, May 15, 2007

Validation in JSF

Validation in JSF can happen at three levels: in the component, in the backing bean, or in a custom validator.

Component Level - For simple 'required/not required' type of validations. Also the code is very component specific. It is within the component and cannot be reused by other components.

Backing Bean Level - This should be used for business requirement type of validations. The validations are specific to the particular business requirements within which the component is being used. These validations also cannot be reused by other components.

Validators - These are reusable validators for validating field sizes, value ranges, etc. We can reuse these validators accross components. JSF comes bundled with some default validators, and we can also create our own custom validators.

No comments: