Two Laptop Bag*
The moose likes Struts and the fly likes specifying different resource bundle in validation.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "specifying different resource bundle in validation.xml" Watch "specifying different resource bundle in validation.xml" New topic
Author

specifying different resource bundle in validation.xml

Nandu Raghu
Greenhorn

Joined: Nov 21, 2003
Posts: 12
HI,
My question is whether we can specify a different resource bundle other than the default ApplicationResources in the validation.xml file. I have a set of error messages defined in another bundle and am wondering how to make use of it in the validation.xml.
I appreciate any help/input.
Thanks.
sandy gupta
Ranch Hand

Joined: Jan 30, 2001
Posts: 228
As you must have figured by now, you could add as many bundles to your application as you want. All you have to do is plug them in in the struts-config just like you plug in the default and then in your jsp you can use something like:
<message-resource parameter="resource1"/>
<message-resource parameter="resource2" key="prop2"/>
<bean:message key="label.key" bundle="prop2"/> -- will disp label.key frm resource2
<bean:message key="label.key" /> -- will display label.key from resource1
Easy enuf i hope
Sahil


Adios
Nandu Raghu
Greenhorn

Joined: Nov 21, 2003
Posts: 12
Hi Sahil,,
I tried doing what you said, but it did not work.
Maybe, we cannot specify any other bundle in the validation.xml. If somebody has had success with this , I would be very interested to know about it.
This is what I am trying to do
In validation.xml.
<arg0 key="label.name" bundle="mybundle"/>
where mybundle is a resource bundle .
David Yutzy
tumbleweed and gunslinger
Ranch Hand

Joined: Jun 29, 2001
Posts: 192
When I tried to specify another resource bundle in the struts-config.xml, I found that one over-rides the other. In my example, I had two bundles:
application.properties
webapp.properties
I kept getting errors from JSP pages that referenced values in application.properties saying that they didn't exist. They don't in webapp.properties.
So I removed webapp.properties and the tags worked and the webapp ones do not.
Not sure what I'm doing incorrectly, but multiple bundles in struts-config.xml isn't working for me.
sha ram
Greenhorn

Joined: Nov 25, 2003
Posts: 12
Hello
I want to use the validation in my page. I have no idea where this validation.xml is? Can you guide me.
Nandu Raghu
Greenhorn

Joined: Nov 21, 2003
Posts: 12
Hi Sha Ram,
The validation.xml should be in the same place where the struts-config.xml is.
sha ram
Greenhorn

Joined: Nov 25, 2003
Posts: 12
I could only see below files under web-inf/lib.
Is there a way I am suppose to add this file. Please help me.
ibm-web-bnd.xmi
ibm-web-ext.xmi
struts-bean.tld
struts-config.xml
struts-html.tld
struts-logic.tld
struts-nested.tld
struts-template.tld
struts-tiles.tld
web.xml
Rick Hightower
Author
Ranch Hand

Joined: Feb 20, 2002
Posts: 350
I looked at the DTD for validation.xml, and there is no way to specify a bundle. It seems like validation.xml only works with the default bundle. Kind of a drag. This might be something they fix in Struts 1.2. Did you see if this was reported in Buggzilla?


Rick Hightower is CTO of Mammatus which focuses on Cloud Computing, EC2, etc. Rick is invovled in Java CDI and Java EE as well. linkedin,twitter,blog
Hao Zhang
Greenhorn

Joined: May 10, 2004
Posts: 4
Hi Rick, I saw in Struts-Example with struts 1.1, the validation.xml contains <field bundle="alternate" property="password" ... />, and it works. But indeed there should be no bundle property according to the DTD, why?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: specifying different resource bundle in validation.xml