File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes struts 2 validation 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 "struts 2 validation" Watch "struts 2 validation" New topic

struts 2 validation

Bunty Paul

Joined: Jun 26, 2006
Posts: 28
I did some validation for the fields in my JSP using struts 2 taglib.
It uses field validator which displays the actionerrors above every field.

But i want to specify that actionerrors be displayed only at the top of the page. How can i do this.
Reda Mokrane
Ranch Hand

Joined: Jul 25, 2001
Posts: 237
At the top of the page add <s:actionerror />

hope this help.
Bunty Paul

Joined: Jun 26, 2006
Posts: 28
Thank you Reda Mokrane.

It helps, for actionerrors. But i need to change my fielderrors to actionerrors. And that definitely gives me pain.

Ok thats how the struts 2 has been designed. What can we do? Oops!
Bunty Paul

Joined: Jun 26, 2006
Posts: 28
Hey, I have figured out the solution.

Thank me, there was a solution.

just set the theme attribute of the form to the value 'simple'.

for example:

<s:form action="" theme="simple">

It's that simple !!!
palas das

Joined: May 09, 2007
Posts: 9
Actually I have created one action class , one jsp,two field for input,and one validation.xml file. field-validator type="requiredstring"> for this line in the xml file anything I have to do or not?
I agree. Here's the link:
subject: struts 2 validation
jQuery in Action, 3rd edition