Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: Formatting
-
Labels:None
-
Environment:Win 7, Java 6, Resin 3.1.10
Description
Reading the Stripes documentation about localization:
<<
Secondly, you should rarely have a need to use the <fmt:setLocale.../> tag. Because of Stripes' strategy of using a filter and a request wrapper, all components in your application, including the JSTL tags, will always get the right locale when they call request.getLocale().
>>
Using the Layout template mechanism I cannot get <fmt:formatDate /> to use the locale returned by my custom LocalePicker - it seems to always use the browsers preferred locale.
If I include <fmt:setLocale value="${pageContext.request.locale}" /> on my page it works fine. But reading the above documentation makes me wonder why thats required?
Is this really a "Major" bug? Sounds to me like a question on why something needs to be coded this way.
An alternative and IMHO much better solution is to do the following in your a BaseActionBean super class that your ActionBeans inherit from:
@SuppressWarnings("unused")
@Before(stages = { LifecycleStage.EventHandling })
private void init() {
HttpServletRequest request = this.context.getRequest();
Locale locale = request.getLocale();
// Load locale specific resource bundle
ResourceBundle bundle = StripesFilter.getConfiguration().getLocalizationBundleFactory().getFormFieldBundle(locale);
// Set resource bundle so that it can be directly used in JSPs
javax.servlet.jsp.jstl.core.Config.set(request.getSession(), Config.FMT_LOCALIZATION_CONTEXT,
new LocalizationContext(bundle, locale));
IIRC this came from Freddy Daoud's book ... .
In any event, I think this bug can be marked closed as it is not an issue.
--Nikolaos