File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Validation of mandantory fields in struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Validation of mandantory fields in struts" Watch "Validation of mandantory fields in struts" New topic

Validation of mandantory fields in struts


Joined: Jan 09, 2006
Posts: 2
Hi all,

I have some of the mandantory fields on my page. I want to show only one message "Please enter all mandantory fields (Mandantory fields are indicated by *)", if any of the required field is not entered. How can I achive this using struts validator framework. Please reply ASAP.

thank & Regards,
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The struts validation framework is designed to produce one error message per error. You could have each validation produce the same error message, but in a case where more than one field is blank, the message will be repeated more than one time.

There may be a way to go in and change the way validation works to accommodate your desire for a single error message, but in my opinion, it isn't worth the effort. A simple javaScript function that you write would be a much easier way to accomplish this.

Consultant, Sima Solutions
Daniel Platon
Ranch Hand

Joined: Oct 10, 2005
Posts: 42
Hello all...

Another way to achieve what you want is using a boolean variable in your form's validate() method, something like:

Hope this helps,

I agree. Here's the link:
subject: Validation of mandantory fields in struts
It's not a secret anymore!