File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of Elasticsearch in Action this week in the Big Data forum!
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=""> refers only to first resource file.....
Junilu Lacar

Joined: Feb 26, 2001
Posts: 5503

Specify the bundle:

<bean:message key="" 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="" bundle="<%= MyGlobals.MYBUNDLE %>" />

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

Joined: Jun 21, 2003
Posts: 10 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(""));
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:
subject: Multiple Message Resource File Problem