Solved

Error messages for Struts validation

Posted on 2004-08-05
3
185 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Let’s face it: one of the reasons your organization chose a SaaS solution (whether Microsoft Dynamics 365, Netsuite or SAP) is that it is subscription-based. The upkeep is done. Or so you think.
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

688 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