Solved

Error messages for Struts validation

Posted on 2004-08-05
3
182 Views
Last Modified: 2010-04-01
I've got a question that I don't think is possible, but I want to make sure!

I have a form field that has a maxlength dependent on other options.  I have written my own validator to check that the length is valid - ( dependent on these other options) , and that works just fine.

Now to take it one step further, it would be ideal if I could have the error message that I have stored from ApplicationResources.properties  be chosen depending on these other options....

So instead of having a generic message: "The length is invalid" or something like that, it could actually say what the length required is.  I can't use the actual maxlength validator that does this, because of the way the fields are being used by multiple name codes.  

So is there a way to choose a different error message from within the validator class, or is it only possible to have one error message per validator, as entered in the validator-rules.xml?

Thanks!
Matt
0
Comment
Question by:Cluniac
3 Comments
 
LVL 35

Accepted Solution

by:
TimYates earned 200 total points
ID: 11727428
If you write your own ActionForm class, and override the validate() method, then you can pass whatever message you want out of ApplicationResources.properties...

http://publib.boulder.ibm.com/infocenter/wsphelp/index.jsp?topic=/com.ibm.etools.struts.doc/html/rstruse0004.htm

has an example of a validate method

0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SEO can be a real minefield to navigate, but there are three simple ways to up your SEO game just be re-assessing your content output.
An article on effective troubleshooting
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now