WebWork 2 : Using Localized Texts in Sitemesh Decorators
This page last changed on Dec 02, 2004 by jcarreira.
In WebWork 2.1.7 and XWork 1.0.5 support was added for supporting the use of the localization services of WebWork in Sitemesh decorators. In the com.opensymphony.xwork.TextProvider Interface, this method was added: public String getText(String aTextName, String defaultValue, List args, OgnlValueStack stack) and this method was added to com.opensymphony.xwork.util.LocalizedTextUtil which com.opensymphony.xwork.TextProviderSupport (the default TextProvider implementation) calls in the implementation of the above method: public static String findText(Class aClass, String aTextName, Locale locale, String defaultMessage, Object[] args, OgnlValueStack valueStack) What this does is to use this value stack and the locale in its context if it's there to find the correct text and resolve any variable subsitutions. The problem before was that down in LocalizedTextUtil it was using ActionContext.getContext().getValueStack() to get the value stack and the Locale, so localized texts wouldn't work in Sitemesh decorators. The TextTag automatically uses this form now, and passes in the value stack it gets from the request if it's there. You can also access this form of the method in OGNL expressions like this: <ww:submit value="%{getText('text.search','Search',null,#request['webwork.valueStack'])}"/>
|
![]() |
Document generated by Confluence on Dec 14, 2004 09:55 |