• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 472
  • Last Modified:

How can I use JSTL fmt:message with Struts custom MessageResources class?

I've seen lots of examples of using fmt:message when you have resource bundles.  However, I need to get my translated strings from a database so I had to create a custom class to extend MessageResources.  I've gotten bean:message to work just fine, but would like the extended functionality of fmt:message.  

Here's what in my web.xml:

Here's what's in my struts-config:

 <message-resources parameter="com.mycompany.MyMessageResources"
            factory="com.myCompany.MyMessageResourceFactory" key="branding"
            null="true" />

Here is what works:
<bean:message key="testMsg" bundle="branding" />

Here is what doesn't work:
<fmt:setBundle basename="com.mycompany.MyMessageResources"
    var="lang" scope="session"/>
<fmt:message key="testMsg" bundle="${lang}"/>

I don't get an error, but it can't seem to find the message either.  Please help!  I've been googling everywhere and can't find any examples of this.  I've tried various values for baseName and the param-value, but nothing seems to be working.

1 Solution

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now