File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Struts2 validation problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2 validation problem" Watch "Struts2 validation problem" New topic

Struts2 validation problem

praveen moturi

Joined: Aug 20, 2009
Posts: 4
please help me thanks in advance
hi iam using struts2 validation.xml for validating the form some times the action is directly submitted witout validating

the validation is not working.this is the code in struts.xml

<action name="AddRegistration" method="addAcceptRegistrationForm"
<interceptor-ref name="defaultStack">

<result name="input" type="redirect">/Resources/registration/addRegistrationForm.jsp</result>
<result name="error">/Resources/registration/Error.jsp</result>

and one more problem which i already posted earlier was the old errors are not getting cleared instead it adds up iam not using springs is there any suggestion what the changes i need to make or where can i remove the old errors
David Newton

Joined: Sep 29, 2008
Posts: 12617

First off, the input page should not be a redirect. If you're not using Spring (singular) I don't see how errors could accumulate, since an instance is created per-request--you're going to need to supply more information. When you do, please make sure you UseCodeTags when posting code or configuration. Unformatted code and configuration is unnecessarily difficult to read.
praveen moturi

Joined: Aug 20, 2009
Posts: 4
thanks for reply

what additionaly information is needed sorry i cant understand iam extending action support class for my action class
and validation.xml in which iam validating my form fields

there are some select boxes in which required vlidation is not working but iam trying other way as min length validation for that

my code is as follows


<field name="registrationFormBean.nationalityId">
<field-validator type="int">

<param name="Min">1</param>
<message> Nationality Is Required </message>

jsp code follows

<s:select name="registrationFormBean.nationalityId"
label="Ntionality" />

the field nationlityId in the bean is of type int

even though i try to validate the field with required it is not validating thats why iam using min length validator instead of required

on more important thing is old errors are not clearing up in the jsp ,the message are adding up

can any please explian to solve the issue i might i have missing some thing is there any additional information i need to post for more clarity

I agree. Here's the link:
subject: Struts2 validation problem
It's not a secret anymore!