users@javaserverfaces.java.net

Re: Required input field not validated

From: Stanimir Stamenkov <stanio_at_yahoo.com>
Date: Sun, 24 Jul 2011 01:10:10 +0300

Fri, 22 Jul 2011 10:40:52 -0500, /Kito Mann/:

> You ran into one of those JSF 1.x nuances: validation is skipped if
> the field value is empty. JSF 2.0 allows validation to occur even if
> the value is null or empty. Is it possible for you to upgrade?

Unfortunately I'm currently stuck with JSF 1.2 for number of other
dependencies which require major code revisit to upgrade. However
it is nice to hear JSF 2.0 has improved in that direction.

The problem for me appears only when the value is null, i.e. when
there's no corresponding parameter submitted. When the value is
empty, the "required" check is triggered just fine.

I may eventually create a custom component (or phase listener) to
validate missing request parameters, searching the "required"
components of the form being currently submitted, verifying the
presence of the needed parameters and issuing validation messages
(along with FacesContext.renderResponse()), if needed.

-- 
Stanimir