jQuery in Action, 3rd edition
The moose likes Struts and the fly likes Multiple Message Resource File Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Multiple Message Resource File Problem" Watch "Multiple Message Resource File Problem" New topic

Multiple Message Resource File Problem

Neeraj Gupta

Joined: Jun 21, 2003
Posts: 10
If you have the following in your struts-config.xml:
<message-resources parameter="ApplicationResources"/>
<message-resources key="CHANNELS_RESOURCE_KEY" parameter="ApplicationResourcesChannels" null="false"/>

Now, how do you access the second message-resource from your JSP....because

<bean:message key="abc.xyz"> refers only to first resource file.....
Junilu Lacar

Joined: Feb 26, 2001
Posts: 6529

Specify the bundle:

<bean:message key="abc.xyz" bundle="CHANNELS_RESOURCE_KEY"/>

You can also use a JSP expression:

// in Java

public class MyGlobals {
public static final String MYBUNDLE = "CHANNELS_RESOURCE_KEY";

// in JSP

<%@page import="MyGlobals" %>
<bean:message key="abc.xyz" bundle="<%= MyGlobals.MYBUNDLE %>" />

Junilu - [How to Ask Questions] [How to Answer Questions]
Neeraj Gupta

Joined: Jun 21, 2003
Posts: 10
Thanks....it works perfectly fine !!!
sonu arora
Ranch Hand

Joined: Jul 25, 2002
Posts: 30

How can we use the same in a java file (Bean file) like..

This is in validate method of Bean Class

ActionErrors errors = new ActionErrors();
errors.add("Name", new ActionError("error.name"));
errors.add("Pass", new ActionError("error.pass"));

At present both keys are in one resource file.
I want to use both entries from 2 different resources.

try & try u ll surely win.
I agree. Here's the link: http://aspose.com/file-tools
subject: Multiple Message Resource File Problem
It's not a secret anymore!