Wednesday, April 29, 2009

Setting up a Resource Bundle in the faces-config.xml file?

 

I just posted this question on JavaRanch. I’m reposting it here, with the answer, so I don’t forget it.

I was doing some internationalization, and all of my resources talk about adding an f:loadbundle tag to every JSP. That seems rather cumbersome. Isn’t there some way to point to the appropriate resource bundle once in the faces-config.xml file or web.xml file, and then not have to re-reference that message bundle or resource bundle on every single JSF view page? I’m positive that I saw that somewhere!

….

Well, apparently, in JSF 1.1 and earlier you do. In JSF 1.2 and on, you can use this little element in your faces-config.xml file.

<application>
    <resource-bundle>
        <base-name>bundles.messages</base-name>
        <var>bundle</var>
    </resource-bundle>
</application>

No comments:

Post a Comment

Followers