I faced a problem regarding loading ResourceBundle at server-side on Seam 2.2 application.
In client side (JSF), it’s OK to use the resource bundle:
<f:facet name="header">#{message['addTest.header.add']}</f:facet>
but on server-side, there’s no way to use Resource bundle.
I tried following methodology but no solution works.
- add to StatusMessage: StatusMessage.addFromResourceBundle(serverity.ERROR, “key_string”);
- Use injection as in this question: Use message bundle in Java class with Seam
-
Load resource bundle:
private java.util.ResourceBundle getResourceBundle() {
org.jboss.seam.core.ResourceLoader resourceLoader = org.jboss.seam.core.ResourceLoader
.instance();
java.util.ResourceBundle resourceBundle = resourceLoader.loadBundle(“message”);
return resourceBundle;
}
but result of this method is null.
Any idea or guidance will be highly appreciated.
Found the problem, the 3rd way works.
It’s because I use 2 resource bundles in my project, one is messages (common) and one is myMessage.
At first, when defining resource bundle in file components.xml, I only define myMessage resource bundle.
In file faces-config.xml, I defined language support.
And when using 3rd way, it only return messages bundle only.
To fix this, only need to add messages bundle into file components.xml and remove name in core:resource-loader.
That’s it.