Solved

Error messages for Struts validation

Posted on 2004-08-05
3
178 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

In this step by step tutorial with screenshots, we will show you HOW TO: Enable SSH Remote Access on a VMware vSphere Hypervisor 6.5 (ESXi 6.5). This is important if you need to enable SSH remote access for additional troubleshooting of the ESXi hos…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

705 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

19 Experts available now in Live!

Get 1:1 Help Now