Skip to main content

Validators of h:inputText not getting invoked when value is ""

3 replies [Last post]
babus_18
Offline
Joined: 2004-10-14
Points: 0

Hi,

I am using jsf api and impl 1.2._12.

I have the following facelet mark up:

The "stateValidator" is configured as follows in faces-config

stateValidator
adc.validators.MultiFieldLengthValidator

The validator is getting invoked with no issues when the value of the field is anything other than "". But when the value is "", the validator does not get invoked.

I am wondering if I am doing something wrong. Please advise on potential solutions.

TIA,
Babu

Message was edited by: babus_18

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Ryan Lubke

webtier@javadesktop.org wrote:
> Hi,
>
> I am using jsf api and impl 1.2._12.
>
> I have the following facelet mark up:
>
>
>
>

>
> The "stateValidator" is configured as follows in faces-config
>
>
> stateValidator
> adc.validators.MultiFieldLengthValidator
>

>
> The validator is getting invoked with no issues when the value of the field is anything other than "". But when the value is "", the validator does not get invoked.
>
> I am wondering if I am doing something wrong. Please advise on potential solutions.
>
In JSF 1.2, validators will not be invoked if the value is null or a
zero-length string.
JSF 2.0 (still under development) loosens this restriction.

You could work around the issue by providing your own UIInput custom
component
that overrides UIInput.validateValue() with the behavior you desire.
Refer to the Facelets
documentation on wiring in a new component.

> TIA,
> Babu
> [Message sent by forum member 'babus_18' (babus_18)]
>
> http://forums.java.net/jive/thread.jspa?messageID=332110
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: webtier-help@glassfish.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: webtier-help@glassfish.dev.java.net

babus_18
Offline
Joined: 2004-10-14
Points: 0

Thank you Lincoln and Ryan.

I also initially thought of over-riding validateValue(). But I am sure the change would have been already made if it was the best thing to do. The fact that it has been accepted as a restriction leads me to think that there is a larger issue. So would wait for JSF 2.0.

Lincoln Baxter, III

JSF doesn't invoke validators on blank fields.

You'll need to set the required="true" attribute in order to enforce
this. It's weird, I know.

You may also be interested in this little tutorial:
http://forums.sun.com/thread.jspa?threadID=523119&messageID=2505792&foru...

Best of luck.

--Lincoln

On Mon, 2009-02-16 at 12:04 -0800, webtier@javadesktop.org wrote:

> Hi,
>
> I am using jsf api and impl 1.2._12.
>
> I have the following facelet mark up:
>
>
>
>

>
> The "stateValidator" is configured as follows in faces-config
>
>
> stateValidator
> adc.validators.MultiFieldLengthValidator
>

>
> The validator is getting invoked with no issues when the value of the field is anything other than "". But when the value is "", the validator does not get invoked.
>
> I am wondering if I am doing something wrong. Please advise on potential solutions.
>
> TIA,
> Babu
> [Message sent by forum member 'babus_18' (babus_18)]
>
> http://forums.java.net/jive/thread.jspa?messageID=332110
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: webtier-help@glassfish.dev.java.net
>
[att1.html]