Dear Stripes maintainers,
In Stripes 1.4, there is a mapping 1 locale --> 1 or 2 resources
bundles (1 for field names, 1 for error messages).
I wanted a page or request could decide to use specific resource
bundle for specific purpose. I imagined the specific resource bundle
could be set:
- In the request scope with some code from an action bean
- In the page using JSTL <fmt:bundle> and <fmt:setBundle> tags or scriptlet
- In the tag: <stripes:errors bundle="${myBundle}"/>
So here is what did:
- I created a LocalizationContext class containing the current Locale
+ methods to get messages from resource bundles (they were previously
static in LocalizationUtility) + optionally a specific resource
bundle. This class is very similar to JSTL's LocalizationContext (same
idea) but not linked.
- In all "Message" subclasses, I changed the signature of methods like
"String getMessage(Locale)" into "String
getMessage(LocalizationContext)"
- In all Tag classes using
LocalizationUtility.getLocalizedFieldName(locale, fieldKey) or
LocalizationUtility.getErrorMessage(locale, errorKey), I put something
like "new
LocalizationContext(getPageContext()).getLocalizedFieldName(fieldKey))"
instead
- LocalizationUtility class became nearly useless since its role was
very close to LocalizationContext one
- Finally, I transformed LocalizationContext into an interface and
created 2 concrete implementations: DefaultLocalizationContext which
should behave exactly like Stripes 1.4 and a JstlLocalizationContext
(should be isolated from Stripes "core" into a plugin has it generates
a dependency between Stripes and JSTL). A factory method put quickly
in the LocalizationBundleFactory makes LocalizationContext
instantiation configurable.
- Now by subclassing LocalizationContext, anybody can tell Stripes
which resource bundle to use.
My Stripes source code is available here (I took the original from
SVN): http://gquintana.free.fr/stripes/stripes-l10patch.tar.bz2
At the moment, it compiles successfully but I didn't have time to test
it (boooh, shame on me). It's more a proof of concept than a patch. If
you find the idea interesting I can test it and document it. If you
feel it's useless/poorly designed/stupid, I won't go further.
Sorry for my poor English and thanks for your work on Stripes,
Gérald
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development