You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by "Zheng, Xiahong" <Xi...@FMR.COM> on 2008/04/24 19:42:04 UTC

JSF validation question?

Two scenarios:

Scenario 1. Form submission:
Our security requirement mandates that we implement some sort of default
validation on fields that do not have validator attached to them. That
is, if validators are missing on the input fields, we have to do some
minimal validation. Otherwise, JSF will do the validation. How would you
go about implementing this requirement. I am thinking several options

A) Use a customized Application implementation which will override
"createComponent" method which delegates to the default ApplicationImpl
to create the component and add my default validator if there is no
validators.

   createComponent(String componentType) {

       UIComponent component = delegate.createComponent(componentType);
       if (component instanceof UIInput &&
component.getValidators.length == 0) {
            component.addValidator(new MyDefaultValidator());
       }
   }

B) Create a custom form component to track the input fields with a
similar logic when they are being added the form. This 

Scenario 2. Get request (no form submission):

  JSF does not execute validation phase for GET request. In this case,
how do I validate request parameters passed as managed properties? I
don't want to validate them explicitly in my managed beans. I want the
validation to happen before they are bound. 

Thanks in advance,
Xiaohong Zheng