aspose file tools*
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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2 validation problem" Watch "Struts2 validation problem" New topic
Author

Struts2 validation problem

praveen moturi
Greenhorn

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"
class="registration.action.RegistrationAction">
<interceptor-ref name="defaultStack">

</interceptor-ref>
<result name="input" type="redirect">/Resources/registration/addRegistrationForm.jsp</result>
<result name="error">/Resources/registration/Error.jsp</result>
<result>/Resources/registration/Success.jsp</result>
</action>



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
Author
Rancher

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
Greenhorn

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

validator.xml

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

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

jsp code follows


<s:select name="registrationFormBean.nationalityId"
list="#session.NationalityList"
listKey="nationalityId"
listValue="nationalityName"
headerKey="0"
headerValue="---select---"
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: http://aspose.com/file-tools
 
subject: Struts2 validation problem