What's the best way for me to this fix in the Wicket 1.1.1 codebase?  Do
I create a CustomValidator with essentially the impl below, and use this
custom validator for my 1.1.1 DropDowns?  

> -----Original Message-----
> From: Eelco Hillenius [mailto:[EMAIL PROTECTED] 
> Sent: Sunday, February 19, 2006 12:33 AM
> To: wicket-user@lists.sourceforge.net
> Subject: Re: [Wicket-user] New RequiredValidator and DropDownChoice
> 
> Ok, I think this is the right fix (it's in HEAD now):
> 
>       public final void onValidate(final FormComponent 
> formComponent, final String value)
>       {
>               // Check value only if form component is enabled
>               if (!formComponent.isEnabled())
>               {
>                       // do not perform validation
>                       return;
>               }
> 
>               // when null, check whether this is natural for 
> that component, or
>               // whether - as is the case with text fields - 
> this can only happen
>               // when the component was disabled
>               if (value == null && (!formComponent.isInputNullable()))
>               {
>                       // this value must have come from a 
> disabled field
>                       // do not perform validation
>                       return;
>               }
> 
>               // peform validation by looking whether the 
> value is null or empty
>               if (Strings.isEmpty(value))
>               {
>                       error(formComponent);
>               }
>       }
> 
> isInputNullable returns true by default, except for text 
> fields, which have empty strings as input even though the 
> user didn't even touch them.
> 
> Agreed?
> 
> Eelco
> 
> On 2/18/06, Eelco Hillenius <[EMAIL PROTECTED]> wrote:
> > Uh, another potential nastier problem is that you put in 
> > disabled="disabled" there yourself either directly or with an 
> > attribute modifier. In that case, the old code makes sense, 
> though it 
> > is not very generic. Hmmmm... what should we do...
> >
> > Eelco
> >
> > On 2/18/06, Eelco Hillenius <[EMAIL PROTECTED]> wrote:
> > > A potential, theoretic issue can be that isEnabled is based on an 
> > > algoritm in such a way that it was false during 
> rendering, but true 
> > > now that the post back comes in. Or the other way around. But I 
> > > think that is too theoretical to worry about, and even if 
> it would 
> > > show up sometime, somewhere for anyone, it would be easy 
> to fix for 
> > > that custom situation.
> > >
> > > Eelco
> > >
> > >
> > > On 2/18/06, Eelco Hillenius <[EMAIL PROTECTED]> wrote:
> > > > I just took a look, and the 'fix' that isInputNullable 
> was wrong; 
> > > > it was fixing the wrong problem in the first place. I 
> removed that 
> > > > method again, and RequiredValidator now looks like:
> > > >
> > > >         public final void onValidate(final FormComponent 
> > > > formComponent, final String value)
> > > >         {
> > > >                 // Check value only if form component 
> can take on a null value
> > > >                 if (formComponent.isEnabled())
> > > >                 {
> > > >                         // Check value
> > > >                         if (Strings.isEmpty(value))
> > > >                         {
> > > >                                 error(formComponent);
> > > >                         }
> > > >                 }
> > > >         }
> > > >
> > > > Could you and anyone else (devs?) interested in this verify 
> > > > whether I didn't forget anything? The orignal code 
> before the fix was:
> > > >
> > > >         public final void onValidate(FormComponent 
> formComponent, String value)
> > > >         {
> > > >                 // if input was null then value was not 
> submitted (disabled field),
> > > >                 // ignore it
> > > >                 // TODO General: For now only a test on 
> a text component is done for the
> > > >                 // disabled == null. Checkbox, 
> RadioChoice or CheckBoxMultipleChoice can
> > > >                 // all be null and not disabled.
> > > >                 if (formComponent instanceof 
> AbstractTextComponent && value == null)
> > > >                 {
> > > >                         return;
> > > >                 }
> > > >
> > > >                 // Check value
> > > >                 if (Strings.isEmpty(value))
> > > >                 {
> > > >                         error(formComponent);
> > > >                 }
> > > >         }
> > > >
> > > > But I think what's in there now is better. Agreed everyone?
> > > >
> > > > Eelco
> > > >
> > > >
> > > > On 2/18/06, Ingram Chen <[EMAIL PROTECTED]> wrote:
> > > > > Latest RequiredValidator only works for 
> > > > > FormComponent.isInputNullable() that return true.
> > > > > So basically RequiredValidator no longer work for 
> FormComponent 
> > > > > like DropDownChoice .
> > > > >
> > > > > I have one use case: the choices List may return zero 
> size, and 
> > > > > by  default, DropDownChoice will insert a Choose 
> One... for me. 
> > > > > If user submit with this blank choice, I need to prompt user 
> > > > > this is required field and he should add more choices before 
> > > > > processing. previously I use RequiredValidator and it works.
> > > > >
> > > > > How do I archive this now ? I knows I can overrwrite
> > > > > DropDownChoice.isInputNullable() or write a customed 
> > > > > Validator... but which is right way to do this ?
> > > > >
> > > > >
> > > > > --
> > > > > Ingram Chen
> > > > > Java [EMAIL PROTECTED]
> > > > > Institue of BioMedical Sciences Academia Sinica Taiwan
> > > > > blog: http://www.javaworld.com.tw/roller/page/ingramchen
> > > >
> > >
> >
> 
> 
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep 
> through log files for problems?  Stop!  Download the new AJAX 
> search engine that makes searching your log files as easy as 
> surfing the  web.  DOWNLOAD SPLUNK!
> http://sel.as-us.falkag.net/sel?cmd=k&kid3432&bid#0486&dat1642
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user
> 
> 


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to