Re: removing validators

2010-02-10 Thread Igor Vaynberg
instead of using the two minimum validators you can implement your own
that performs/delegates validation based on the convertedinput value
of the first ddc.

-igor

On Tue, Feb 9, 2010 at 11:13 PM, Tony Wu e90t...@gmail.com wrote:
 In total I have 4 DropDownChoices:

 I have a DropDownChoice which allows a user to select whether they are an
 adult or minor. I have another FormComponentPanel with 3 DropDownChoices
 representing their birthdate (year, month, day) with a setConvertedValue set
 to how old they are. I have 2 validators (MinimumValidator(18) for adults,
 and MaximumValidator(17) for minors) that need to be added dynamically based
 on the DropDownChoice (adult vs. minor). So my code is dynamically doing
 FormComponentPanel.add(---min or max validator--).

 However, if a user selects minor from the first dropdown, and the other
 dropdowns with a birthday that puts them at, say age 30.. I will get a form
 validation error - which is good since the Maximum validator kicked in for
 minors. But if I change the dropdown from minor to adult, the code does a
 removeAll() (which should remove all children from FormComponentPanel),
 readds the drop down, and then adds the MinimumValidator(18). At this point,
 it seems like both validators are still in effect - so this is:

 1. Clunky
 2. Doesn't work (the minimum validator seems to still be there even after a
 removeAll, which makes ANY birthday selection at this point invalid since
 both validators are in effect)

 Any ideas on how to remove validators or best approach this? The crux of the
 problem is I want to switch the Component's validator from one, to another.

 Thanks,
 Tony


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



removing validators

2010-02-09 Thread Tony Wu
In total I have 4 DropDownChoices:

I have a DropDownChoice which allows a user to select whether they are an
adult or minor. I have another FormComponentPanel with 3 DropDownChoices
representing their birthdate (year, month, day) with a setConvertedValue set
to how old they are. I have 2 validators (MinimumValidator(18) for adults,
and MaximumValidator(17) for minors) that need to be added dynamically based
on the DropDownChoice (adult vs. minor). So my code is dynamically doing
FormComponentPanel.add(---min or max validator--).

However, if a user selects minor from the first dropdown, and the other
dropdowns with a birthday that puts them at, say age 30.. I will get a form
validation error - which is good since the Maximum validator kicked in for
minors. But if I change the dropdown from minor to adult, the code does a
removeAll() (which should remove all children from FormComponentPanel),
readds the drop down, and then adds the MinimumValidator(18). At this point,
it seems like both validators are still in effect - so this is:

1. Clunky
2. Doesn't work (the minimum validator seems to still be there even after a
removeAll, which makes ANY birthday selection at this point invalid since
both validators are in effect)

Any ideas on how to remove validators or best approach this? The crux of the
problem is I want to switch the Component's validator from one, to another.

Thanks,
Tony