Yes. It looks like a bug On Fri, Jun 3, 2011 at 12:47 PM, Alexandros Karypidis <akary...@yahoo.gr> wrote: > Hello again, > > I'm in a weird place. I've stepped through the code and located my problem > in: > > http://svn.apache.org/repos/asf/wicket/releases/wicket-1.5-RC4.2/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java > > At line 1383, the method "validateValidators()" visits all validators. While > iterating, it reaches my validator BUT decides to skip it because of the > check on line 1398: > > if (isNull == false || validator instanceof INullAcceptingValidator<?>) > > The problem is that my validator is "wrapped" by class "ValidatorAdapter": > > http://svn.apache.org/repos/asf/wicket/releases/wicket-1.5-RC4.2/wicket-core/src/main/java/org/apache/wicket/validation/ValidatorAdapter.java > > As you can see, this class implements IValidator<T> and therefore the check > fails, even though the value of the "wrapped" validator is in fact an > instance of INullAcceptingValidator. > > I would have got the expected behavior if the check was written as: > > if (isNull == false > || validator instanceof INullAcceptingValidator<?> > || ( > // wicket should check against the actual validator: > validator instanceof ValidatorAdapter<T> && > validator.getValidator() iinstanceof > INullAcceptingValidator<?>) > ) > > Could this be a bug? > > On Fri, 03 Jun 2011 12:05:46 +0300, Martin Grigorov <mgrigo...@apache.org> > wrote: > >> Maybe org.apache.wicket.markup.html.form.FormComponent.isInputNullable() >> which is overridden by >> org.apache.wicket.markup.html.form.AbstractTextComponent.isInputNullable() >> >> On Fri, Jun 3, 2011 at 12:00 PM, Alexandros Karypidis <akary...@yahoo.gr> >> wrote: >>> >>> Hello, >>> >>> 1) I have a custom validator that implements INullAcceptingValidator. >>> 2) A TextField component in my form has validator (1) attached to it and >>> is >>> setRequired(false). >>> 3) When I submit my form with the text input empty, the validator does >>> NOT >>> get called. It only gets called if there is a value with the HTML input >>> field. >>> >>> I was expecting that the validator would be invoked upon submission even >>> if >>> the text field is empty, in order to validate tha value "null". At least >>> this is what I understand as far as INullAcceptingValidator goes. >>> However, >>> this does not appear to happen. Instead, Wicket goes on to call the >>> form's >>> onSubmit() method with the value "null" inside my model. >>> >>> What am I missing? >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org >>> For additional commands, e-mail: users-h...@wicket.apache.org >>> >>> >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >
-- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org