File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Struts validation not happening Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts validation not happening" Watch "Struts validation not happening" New topic
Author

Struts validation not happening

nishad km
Greenhorn

Joined: Oct 14, 2004
Posts: 7
Hi ,

In struts validation.xml i have the following code.

<field property="emailId"
depends="isrequired,email,maxlength,validateEmail" page="1">
<arg0 key="global.prompt.emailaddress"/>
<arg1 key="${var:maxlength}" name="maxlength"
resource="false"/>
<var>
<var-name>maxlength</var-name>
<var-value>50</var-value>
</var>
</field>

I need to do the validation only if page =1. In action class before calling validator i am setting page =1. but validation is not happening. if i remove the page=1 then validation is happening.

Action class code follows.

profileForm.setPage(1);
ActionErrors errors = super.validateForm((ValidatorForm) form, mapping, request);

can any one help me on this
Srinivasan thoyyeti
Ranch Hand

Joined: Feb 15, 2007
Posts: 557
This is not struts forum


Thanks & Regards, T.Srinivasan
SCWCD 1.4(89%), SCJP 5.0(75%)
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Try setting the page number in the JSP like this:

Also, "isrequired" should be "required" and "validateEmail" should be "email".


Merrill
Consultant, Sima Solutions
Poorna Chandra Tejashvi
Greenhorn

Joined: Aug 28, 2007
Posts: 1
The ActionForm should extend the ValidatorForm .
Then you should write the error messages what you want to display in message.properties.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Struts validation not happening