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 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.