File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes accessing messageressource in taglib Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "accessing messageressource in taglib" Watch "accessing messageressource in taglib" New topic

accessing messageressource in taglib


Joined: Jan 09, 2002
Posts: 26
hello all,
has anybody an idea how i can access the MessageRessources in a Taglib ?
andreas spiessl
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
You can do it the dirty way:
private static MessageResources messages = MessageResources.getMessageResources("lae.resources.ApplicationResources");

the complex way:
private static MessageResources messages;
protected MessageResources getResources()
if (messages == null)
ActionMappings mappings;
mappings = (ActionMappings) pageContext.getAttribute(Action.MAPPINGS_KEY
ActionServlet servlet = mappings.getServlet();
messages = servlet.getResources();
return messages;
or perhaps there is a nicer way to get the resources without knowing the name of the resource file.
I agree. Here's the link:
subject: accessing messageressource in taglib
It's not a secret anymore!