On Tue, 2004-04-27 at 13:21, Marc Portier wrote:
Bruno Dumon wrote:
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?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?
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
well).
Cool job! We can get rid of these ugly CocoonComponentManager hacks.
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)
I was about to propose to not only remove FormContext from validate (it's useless), but also to remove FormContext completely.
Don't yell at me right now. Read on ;-)
Remember those discussions we had last august about request adapters [1] which turned out to be actually environment adapters [2]? Using a LocaleAdapter would allow us to finally use *the* location where we naturally can get it: request.getLocale().
It's just a matter of writing a RequestWrapper that returns the locale accordingly to the browser/cookie/session-attr scheme we have today, and we can stop worrying about these locale that have to be passed around in the code and these {lang} everywhere in the sitemap.
WDYT?
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
You shouldn't need the locale to validate after a setValue, since the value is locale-independent (it's the convetor's job).
Sylvain
[1] http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=106131747919501&w=2 [2] http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=106164807007073&w=2
-- Sylvain Wallez Anyware Technologies http://www.apache.org/~sylvain http://www.anyware-tech.com { XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }
