Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

specifying different resource bundle in validation.xml

 
Nandu Raghu
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Nandu Raghu
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sha Ram,
The validation.xml should be in the same place where the struts-config.xml is.
 
sha ram
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 350
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Hao Zhang
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic