Hello Stanimir,
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?
---
Kito D. Mann | twitter: kito99 | Author, JSF in Action
Virtua, Inc. | http://www.virtua.com | JSF/Java EE training and consulting
http://www.JSFCentral.com - JavaServer Faces FAQ, news, and info | twitter:
jsfcentral
+1 203-404-4848 x3
* Listen to the latest headlines in the JSF and Java EE newscast:
http://blogs.jsfcentral.com/roller/editorsdesk/category/JSF+and+Java+EE+Newscast
* Keep up with the aftermath of the Oracle/Sun merger:
http://www.mergerspeak.com
On Thu, Jul 21, 2011 at 8:29 PM, Stanimir Stamenkov <stanio_at_yahoo.com>wrote:
> I'm using JSF 1.2 (with Facelets) and a form like:
>
> <html xmlns="http://www.w3.org/1999/xhtml"
> xmlns:h="http://java.sun.com/jsf/html">
> ...
> <h:messages />
> <h:form id="test">
> <label>
> Field:
> #{''}
> <h:inputText id="field" value="myBean.field" required="true" />
> </label>
> #{''}
> <h:commandButton value="Submit" action="myBean.action" />
> </h:form>
> ...
> </html>
>
> I've noticed if I remove the text input element on the client side
> (e.g. using the various browser DOM inspecting tools available) and
> submit the form, then the "required" check for the
> <h:inputText id="field"> component is not performed, therefore the
> "myBean.action" executed, where it fails because it assumes the
> "myBean.field" has been set appropriately. What is the rationale
> behind this behavior? Could it be customized to always require a
> "field" value submitted?
>
> Further, if "myBean.field" had a previous non-empty value set,
> submitting no "field" by the client leaves the old value in place,
> no validation errors, and "myBean.action" executed referring to the
> old value, in which case the outcome may not be desired.
>
> --
> Stanimir
>