aspose file tools*
The moose likes Struts and the fly likes bean:message in a java class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "bean:message in a java class" Watch "bean:message in a java class" New topic
Author

bean:message in a java class

Jörgen Lundberg
Greenhorn

Joined: Dec 08, 2005
Posts: 10
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 ]
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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.


Merrill
Consultant, Sima Solutions
Akhilesh Trivedi
Ranch Hand

Joined: Jun 22, 2005
Posts: 1526
what does bean:message do? can somebody provide html/scriptlet equivalent of the same.


Keep Smiling Always — My life is smoother when running silent. -paul
[FAQs] [Certification Guides] [The Linux Documentation Project]
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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.
Akhilesh Trivedi
Ranch Hand

Joined: Jun 22, 2005
Posts: 1526
thanks merill.. where is the properties file configured, i mean the point of association between the property file and this tag...
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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.
Akhilesh Trivedi
Ranch Hand

Joined: Jun 22, 2005
Posts: 1526
Thank you merill.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: bean:message in a java class