SashikaXP
SashikaXP

Reputation: 817

jsf2 loading a resource bundle defined defined in a JAR

I'm creating a modular JSF 2.0 application and each of the modules has their own faces-config and the facelet pages. These modules are packaged into JAR and consumed in a master JSF2 application. Everything works fine but the resource bundles defined in each of the faces-config files are not resolved at the runtime. Not resolved means the respective text is not displayed in the pages. I refer to the message as <h:outputText value="#{msg['message1']}" />

how do I make it work?

Upvotes: 2

Views: 1342

Answers (3)

When packed as jar, faces-config.xml must be at /classes/META-INF/ dir, and it is not necessary to add the f:loadBundle in each facelet

Upvotes: 0

Claudiomir
Claudiomir

Reputation: 129

This is an old topic but maybe could help someone.

Another possible solution is to declare two different bundles in faces-config.xml. Something like that:

<application>
    <resource-bundle>
        <base-name>msgsprj</base-name>
        <var>msgsPrj</var>
    </resource-bundle>

    <resource-bundle>
        <base-name>msgsfmk</base-name>
        <var>msgsFmk</var>
    </resource-bundle>
</application>

So in your XHTML's you can use them this way:

#{msgsFmk['generic.msg.remove']}

As well it would be good idea to take a look at this topic:

Using Multiple Resource bundles in JSF

Upvotes: 2

SashikaXP
SashikaXP

Reputation: 817

After some research it seems, resource-bundles defined in faces-config files in a JAR file are not resolved at run time. The only solution is to use <f:loadBundle var="msg" basename="messages"/> explicitly in the facelet page. Then it will resolve the messages.properties inside the JAR file.

Upvotes: 5

Related Questions