cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bruno Dumon <>
Subject Re: WidgetValidators: do they need FormContext?
Date Tue, 27 Apr 2004 13:13:16 GMT
On Tue, 2004-04-27 at 13:21, Marc Portier wrote:
> Bruno Dumon wrote:
> > I was just looking at adding widget validators on widget instances and
> > found it's already there. Cool :-)
> > 
> > Still a question about the WidgetValidator interface:
> > 
> > public interface WidgetValidator {
> >     boolean validate(Widget widget, FormContext context);
> > }
> > 
> > will a validator ever need the FormContext object?
> > 
> I had the same question popin' up when looking at validate(FormContext) 
> on widget.. only thing I could imagine was that it might be useful to 
> have access to the Locale?

the Locale shouldn't even be needed.

Just found a possible reason: until recently the flowcontext, which is
passed on to the javascript validator snippets, was passed on via the
request object. Now that's done via the objectModel so at least for that
purpose it's not needed anymore. (and I've made the listenerbuilders
into 'real' avalon components so they could get it via contextualize as

> And I would need to take a deeper look but probably one could (today) 
> obtain the same through widget.getFormDefinition().getLocale()

typo: getForm() instead of getFormDefinition()

I think we should keep that method for internal purposes only (I would
make that method protected). Normally the locale is only needed during
the readFromRequest/conversion cycle, but because that conversion is now
sometimes delayed till the getValue, the locale needs to be stored as
well. (I know you know that, just mentioning it for the audience)

> this assumes that validation is called after readFromRequest() (no pro) 
> but would also assume that if validation needs to happen after binding 
> (doesn't ATM) this locale on form should be set
> regards,
> -marc=
Bruno Dumon                   
Outerthought - Open Source, Java & XML Competence Support Center                

View raw message