use resource bundle outside of Action in struts 2
i have to generate some logs in struts 2 framework. i know the action classes include resource bundle feature by just using getText() method. but i can’t find how i use resource bundle outside of Action classes. just google it and get no reasult.
i didn’t give up and download xwork2.0.7. (yes, xwork!) struts2.0.x source doesn’t contain old xwork code. and finally found some classes about that. DefaultTextProvider and LocalizedTextUtil. DefaultTextProvider is just a wrapper of LocalizedTextUtil.
1 2 | TextProvider textProvider = DefaultTextProvider.INSTANCE; log.info(textProvider.getText("some.property")); |
i have to use Locale.US for logging. so…
1 | LocalizedTextUtil.findDefaultText("some.property", Locale.US) |
struts 2 has many good features but lacks of manual.. anyway, we can do what we want. if you don’t care about reading sources.. good luck to you

