File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "specifying different resource bundle in validation.xml" Watch "specifying different resource bundle in validation.xml" New topic

specifying different resource bundle in validation.xml

Nandu Raghu

Joined: Nov 21, 2003
Posts: 12
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.
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

Nandu Raghu

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="" 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:
I kept getting errors from JSP pages that referenced values in saying that they didn't exist. They don't in
So I removed 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

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

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

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

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:
subject: specifying different resource bundle in validation.xml
It's not a secret anymore!