I'm replacing lots of duplicated html/struts-code with a custom tag. The problem with the code I'm replacing is that it contains <bean:message-tags. Obviously I can't just write "<bean:message..." from inside my tag-java code. How can I call the equivalent struts code from java instead of from my html/struts page? [ August 09, 2007: Message edited by: J�rgen Lundberg ]
When you downloaded Struts, if you selected the "full distribution", you got the source code with the download. Just look at the source code for the org.apache.struts.taglib.bean.MessageTag class and you'll see how to get a message from a given key.
The bean:message tag renders the message for a given key stored in a properties file. This tag is equivalent to the JSTL <fmt:message> tag and is used mostly for internationalization.
Joined: Jun 22, 2005
thanks merill.. where is the properties file configured, i mean the point of association between the property file and this tag...
Joined: Feb 15, 2005
The properties file or files to be referenced is definied in the struts-config.xml file with an entry similar to the following:
This means that Struts will look for a file named MessageResources.properties somewhere in the classpath. If you're using internationalization, you can also have properties files for different languages. For example, you could have a file named MessageResources_es.properties containing messages in the Spanish language and another named MessageResources_it.properties containing messages in Italian. Struts would then display the message in the language specified in the browser settings.