Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multiple Message Resource File Problem

 
Neeraj Gupta
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Pie
Posts: 8803
81
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 %>" />
 
Neeraj Gupta
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks....it works perfectly fine !!!
HAPPY NEW YEAR TO YOU....
 
sonu arora
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic