Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
Some implementation methods in tapestry core still use direct instantiation of ComponentResourceSelector instead of delegating to ComponentRequestSelectorAnalyzer, namely:
in ComponentMessageSourceImpl.java
public Messages getMessages(ComponentModel componentModel, Locale locale) { return getMessages(componentModel, new ComponentResourceSelector(locale)); } public Messages getApplicationCatalog(Locale locale) { return messagesSource.getMessages(appCatalogBundle, new ComponentResourceSelector(locale)); }
in ComponentTemplateSourceImpl.java
public ComponentTemplate getTemplate(ComponentModel componentModel, Locale locale) { return getTemplate(componentModel, new ComponentResourceSelector(locale)); }
Which makes it impossible to use axes with message bundles and component templates.
Default implementation of ComponentRequestSelectorAnalyzer interface uses ThreadLocale instead of directly passed Locale instance. To workaround this above methods may temporarily set passed locale into ThreadLocal and restore original value after `#buildSelectorForRequest` is returned, i.e.:
public Messages getMessages(ComponentModel componentModel, Locale locale) { Locale original = threadLocale.getLocale(); try { threadLocale.setLocale(locale); return getMessages(componentModel, analyzer.buildSelectorForRequest()); } finally { threadLocale.setLocale(original); } }
{{}}