I am using the DisplayTag library with Struts2. In the
displaytag.properties file, I had to specify a property as follows:
Locale.provider=com.setech.displaytag.I18nWebworkAdapter
This class contains the following method:
ublic String getResource(String resourceKey, String defaultValue, Tag
tag,
PageContext pageContext)
{
String key = (resourceKey != null) ? resourceKey : defaultValue;
String msg = null;
ValueStack stack = TagUtils.getStack(pageContext);
Iterator iterator = stack.getRoot().iterator();
while(iterator.hasNext()) {
Object o = iterator.next();
if(o instanceof TextProvider) {
TextProvider textProvider = (TextProvider) o;
msg = textProvider.getText(key, null, (String)null);
if(msg != null) break;
}
}
if(msg==null && resourceKey != null) {
msg = "???" + key + "???";
log.debug(Messages.getString("Localization.missingkey",resourceKey));
}
return(msg);
}
This method works excellent if the key is detected for the current
locale of the browser; however the text provider does not fall back to
the default values should a key not be found within the current locale.
For example, if de_DE is my present Locale yet no key exists in the
property file for the message yet it exists in en_US, I would want the
en_US value to be displayed.
The normal text provider concept in Struts2 behaves this way; however I
am not sure why the TextProvider above does not.
The iterator finds two providers in the stack:
com.setech.seek.struts2.action.SearchPurchaseOrdersAction
com.opensymphony.xwork2.DefaultTextProvider
Thoughts?
Chris
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]