Thomas Lutz wrote:
Leszek Gawron wrote:
Thomas Lutz wrote:
private Locale locale = Locale.getDefault();
It takes the default locale from the host, but shouldn't it take the
locale set via the browser or the LocaleAction.java ? So the line
should rather be something like:
private Locale locale = I18nUtils.findLocale(....); ?
in your own cocoon webapp you can do:
var form = new Form( "cocoon:/form-def/" + config.filterModelName );
form.locale = determineLocale();
and implement determineLocale() with any logic you like.
For cocoon samples: we should probably make use of LocaleAction.
I tried to do this in javaflow (as I only use java as flow script
language), that's not that easy.
org.apache.cocoon.forms.formmodel.Form.java has no setter for it's
member locale, and locale is private... so no chance of tweaking in ?
I do not know how you do it in javaflow but here is how
HandleFormSubmitAction does it:
Form form = formManager.createForm(source);
Request request = ObjectModelHelper.getRequest(objectModel);
FormHandler formHandler = null;
if (formHandlerClassName != null) {
// TODO cache these classes
Class clazz = Class.forName(formHandlerClassName);
formHandler = (FormHandler)clazz.newInstance();
LifecycleHelper.setupComponent(formHandler, null, null, manager, null);
form.setFormHandler(formHandler);
}
FormContext formContext = new FormContext(request, locale);
boolean finished = form.process(formContext);
request.setAttribute(formAttribute, form);
you can pass locale via FormContext instance.
What's the reason for Locale.getDefault() ? At least I would expect to
behave forms like all other I18N components, and take the locale from
the user agent, so dates and whatsoever get a proper formatting in the
forms... or am I missing something ?
I think this is a good choice that core cforms classes do not depend on
environment. Every user is free to choose the method to determine
locale. You could implement a scenario where locale is fetched from user
personal settings stored in database.
--
Leszek Gawron [EMAIL PROTECTED]
IT Manager MobileBox sp. z o.o.
+48 (61) 855 06 67 http://www.mobilebox.pl
mobile: +48 (501) 720 812 fax: +48 (61) 853 29 65