Multiple Resource Bundles in JSF

All,

How can I have multiple resource bundles in JSF application.

let's say, I want to have all the login screen messages in 'login-messages.properties' file and all the order entry messages in 'order-messages.properties' file.

For a single message properties, this is how we declare in faces-config.

<application>

<message-bundle>messages</message-bundle>

<locale-config>

<default-locale>en</default-locale>

</locale-config>

</application>

I'm pulling the resource bundle in the bean object in the following way:

Application application = FacesContext.getCurrentInstance().getApplication();

String bundleName = application.getMessageBundle();

Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale();

ResourceBundle rb = ResourceBundle.getBundle(bundleName, locale);

String value = rb.getString("invalid.user");

I would like to have module specific properties file and pull the messages accordingly. Any help with this is greatly appreciated.

Thanks,

Sridhar.

[1176 byte] By [vuduthaa] at [2007-11-26 19:27:19]
# 1

You don't have to get the base name from the application. You can use whatever you want, allowing for multiple names.

Also, in some cases, you may want to reference messages from the .jsp / .jsf file... you can use:

<f:loadBundle basename="org.example.Messages" var="msgs" />

Then:

#{msgs['key']}

I hope this helps.

Good luck!

Ken Paulsen

https://jsftemplating.dev.java.net

KenPaulsena at 2007-7-9 21:53:34 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...