Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts Validator

 
Thara Visu
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
Am using the struts validator for an application

Can i have the error messages in one properties file and labels in another?
For example


My ErrorMessages.properties file consists of the following
errors.required = Please enter valid {0}

My Labels.properties file consists of the following
label.UserID = User ID

The struts config is set up as


Am accessing the html:errors as <html:errors bundle="Errors">

How do I associate the label.UserID with my error message.
I tried the following method

It doesnt work.

Any inputs?

 
Thara Visu
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any inputs on this topic... Guys It would be a great help
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No real input from me...I have never used the bundle attribute of the html:errors tag. It looks like it does not support pulling messages from one resource bundle and field names from another bundle. My guess is that you will have to include these both in the same resource bundle.

- Brent
 
Dhana Sen
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<form-validation><formset> <form name="loginForm">
<field property="txtUserName" depends="required">
<arg0 key="label.UserID"/> # this u'r field Name


</field>
</form>
</formset>
</form-validation>

U'r ErrorMessages.properties file consists of the following
errors.required = Please enter valid {0}

check it out it will work

or reply to the post

by
dhana
 
Alec Lee
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the same problem, too. The problem is not related to any tag. Rather, it is the <arg0 key="..."/> tag of validation.xml seems to search for the key in the default message resource only. I did search thru the DTD for the validation.xml and validator-rules.xml but there doesn't seem to be any tag allowing us to specify the message resource to use in the <arg0 key=> attribute.

Greatly appreciate any advice. Thx in advance.
 
Alec Lee
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just discovered that the problem has been solved in validator_1.2.dtd. Here, there is a bundle attribute for specifying which message resource to search for the key.
 
Thara Visu
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks All.
Alec, You told me wanted I really wanted. Thanks pal.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic