File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Struts Validator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts Validator " Watch "Struts Validator " New topic
Author

Struts Validator

Thara Visu
Ranch Hand

Joined: May 17, 2005
Posts: 87
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<br />SCJP 1.4 96%<br />SCBCD 1.3 96%
Thara Visu
Ranch Hand

Joined: May 17, 2005
Posts: 87
Any inputs on this topic... Guys It would be a great help
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
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

Joined: Mar 05, 2006
Posts: 33
<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

Joined: Jan 28, 2004
Posts: 569
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

Joined: Jan 28, 2004
Posts: 569
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

Joined: May 17, 2005
Posts: 87
Thanks All.
Alec, You told me wanted I really wanted. Thanks pal.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Struts Validator