You could try extending from PatternValidator en override onValidate
like this:
public void onValidate(String value)
{
// Check value against pattern
if (value != null && !pattern.matcher(value).matches())
{
error();
}
}
Actually, I think 'ignore when null' behaviour should be default for all
validators except the RequiredValidator, as it is the sole task of the
RequiredValidator to check this. So, I'll patch the validators that are
in core to behave like this (some allready did, but others like
PatternValidator didn't).
Eelco
叶卫国 wrote:
>:-) i think i don't express my question accurately. i use PatternValidator to
>validate fax number, the fax number is optional, that is , user don't need to
>input the value, but if he/she inputed something, it must match the pattern.
>
>Wicket doesn't has a required property for PatternValidator (and all other
>validators), so when i keep the fax number field blank, the validation failed
>too, it's not my original idea.
>
>
>======= 2005-05-01 15:24:08 您在来信中写道:=======
>
>
>
>>On 5/1/05, 叶卫国 <[EMAIL PROTECTED]> wrote:
>>
>>
>>>Say that my form has a field for fax, it's not required, but when user input
>>>something, it must be a valid fax number.
>>>
>>>what can i do?
>>>
>>>
>>>
>>Basically you've two options: client-side and server-side validation.
>>Wicket offers a solution for both. For client-side validation please
>>see my previous mail. For server side valdation please see the
>>forminput example.
>>
>>
-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.
Get your fingers limbered up and give it your best shot. 4 great events, 4
opportunities to win big! Highest score wins.NEC IT Guy Games. Play to
win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user