I also contributed the RequestFilter in different phases ("before:*", "before:SetupRender", "before:BeginRender") because, to me, this should set the locale before any template is rendered.
But it didn't work. I've tried now again and set the things you said before. By the way, thanks for the tips :-) . I removed the unnecesary interfaces and cleaned up after I mailed the, how it worked. It still doesn't work. My code now: public static void bind(ServiceBinder binder) { binder.bind(AjaxUploadDecoder.class, AjaxUploadDecoderImpl.class).scope(ScopeConstants.PERTHREAD); // I also use this, that should not affect the locale binder.bind(TimingFilter.class).withSimpleId(); binder.bind(LocaleRequestFilter.class).withSimpleId(); } public static void contributeRequestHandler( OrderedConfiguration<RequestFilter> configuration, @InjectService("TimingFilter") TimingFilter timingFilter, @InjectService("LocaleRequestFilter") LocaleRequestFilter localeRequestFilter) { configuration.add("TimingFilter", timingFilter); configuration.add("LocaleRequestFilter", localeRequestFilter, "before:*"); } And the LocaleRequestFilter.java: public class LocaleRequestFilter implements RequestFilter { private Cookies cookies; private LocalizationSetter localizationSetter; public LocaleRequestFilter(Cookies cookies, LocalizationSetter localizationSetter) { this.cookies = cookies; this.localizationSetter = localizationSetter; } @Override public boolean service(Request request, Response response, RequestHandler handler) throws IOException { TranslatedLanguage preferredLanguage; String languageValueInCookie = cookies.readCookieValue(PlainTraySetting.COOKIE_LANGUAGE_VALUE_NAME); // some logic to set the correct locale to prefferedLanguage, which is an enum. localizationSetter.setLocaleFromLocaleName(preferredLanguage.toString()); return handler.service(request, response); } } On 08.02.2013 12:59, Lance Java wrote: > René, tapestry also supports locale specific assets (eg images) so a > ComponentRequestFilter is too late in the request-processing pipeline > (http://tapestry.apache.org/request-processing.html). > > I think your main problem is that you have contributed your localeFilter > "after:*" so it won't run until after all of the components have rendered > which is pretty useless. If you contribute it "before:*" I assume it would > work. > > Also, in your code, I can see a few problems: > > 1. You have not specified an interface in you bind methods > > eg: > public static void bind(ServiceBinder binder) { > binder.bind(TimingFilter.class).withId("TimingFilter"); > binder.bind(LocaleRequestFilter.class).withId("LocaleRequestFilter"); > } > > should be: > public static void bind(ServiceBinder binder) { > binder.bind(RequestFilter.class, TimingFilter.class).withSimpleId(); > binder.bind(RequestFilter.class, > LocaleRequestFilter.class).withSimpleId(); > } > > 2. You inject services but never use them > > eg: > public void contributeRequestHandler(OrderedConfiguration<RequestFilter> > configuration, > final Logger logger, > final RequestGlobals requestGlobals, > final Cookies cookies, > final LocalizationSetter localizationSetter, > @InjectService("TimingFilter") RequestFilter timingFilter, > @InjectService("LocaleRequestFilter") RequestFilter localeRequestFilter) > { > configuration.add("TimingFilter", new TimingFilter(logger)); > configuration.add("LocaleRequestFilter", new > LocaleRequestFilter(requestGlobals, cookies, localizationSetter), > "after:*"); > } > > should be: > public void contributeRequestHandler(OrderedConfiguration<RequestFilter> > configuration, > final Logger logger, > final RequestGlobals requestGlobals, > final Cookies cookies, > final LocalizationSetter localizationSetter, > @InjectService("TimingFilter") RequestFilter timingFilter, > @InjectService("LocaleRequestFilter") RequestFilter localeRequestFilter) > { > configuration.add("TimingFilter", timingFilter); > configuration.add("LocaleRequestFilter", localeRequestFilter, > "before:*") > } > > > > > -- > View this message in context: > http://tapestry.1045711.n5.nabble.com/How-to-call-locale-properties-file-based-on-urls-tp5719862p5719871.html > Sent from the Tapestry - User mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org