myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Holger Prause <>
Subject Re: inputCalendar validator
Date Fri, 01 Dec 2006 19:37:49 GMT
Whitmire, Tracy Carroll schrieb:
> Hi,
> I'm using t:inputCalendar and have a question I'm sure someone has 
> already addressed. But a google search was futile.
> If a user decides to enter the input in manually …. What's the best 
> way to validate this input?
> I have a user who loves to enter the date as MM/dd/YY ignoring the 
> help text
> But the expected is MM/dd/yyyy
> So when he enters 12/01/06 ….
> It gets entered into the database as Dec, 01, 0006
> Thanks for your help,
> tc
I use the following code to do that (just write a validator like u are 
used to it in jsf)

<t:inputCalendar id="birthDate"

where validators is a bean and returns a new Validator Object (u can 
play around a bit and register the validator in faces-config.xml but i 
choosed this approach).
Just write a validator like in jsf.

public class BirthDateValidator implements Validator {

public void validate(FacesContext fc, UIComponent uic, Object o) {
//do validation here


thats it, i was suprised it works like i "expected"

View raw message