my dog learned polymorphism*
The moose likes Struts and the fly likes Struts Validation not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts Validation not working" Watch "Struts Validation not working" New topic
Author

Struts Validation not working

Mallika R Kumar
Ranch Hand

Joined: Jan 21, 2004
Posts: 38
Hi,
I am trying to get validation framework to work in my application. I have two jsp pages that use the validator framework with struts - while the first jsp page, login.jsp executes validations fine(checking required and minlength rules for login and password fields), the second page, myPage is not executing validations at all. Here are the relevant tags for myPage.jsp :
form-bean tags for "myForm" from struts-config.xml:
<form-bean name="myForm" type="org.apache.struts.validator.DynaValidatorActionForm">
<form-property name="name" type="java.lang.String"/>
<form-property name="desc" type="java.lang.String"/>
</form-bean>
The action mapping tags from struts-config.xml are:
<action path="/myPage"
type="struts.actions.MyPageAction"
name="myForm"
scope="request"
validate="true"
input="/myPage.jsp">
<forward name="failure" path="/errorpage.jsp"/>
<forward name="success" path="/menu.jsp"/>
</action>
Tags from my validation.xml are as follows:
<formset>
<form name="/myPage">
<field
property="name"
depends="required,minlength">
<arg0 key="mypage.label.name"/>
<arg1 name="minlength" key="5" resource="false"/>
</field>

<field
property="desc"
depends="required,minlength">
<arg0 key="mypage.label.desc"/>
<arg1 name="minlength" key="${var:minlength}" resource="false"/>
<var>
<var-name>minlength</var-name>
<var-value>5</var-value>
</var>
</field>
</form>
</formset>
I am using two formset tags, one for each jsp page. While the login.jsp page's validations work fine, I am unable to get "myPage.jsp" validations to work. I will appreciate any insight into this problem.
Thanks,
Mallika.
Rick Hightower
Author
Ranch Hand

Joined: Feb 20, 2002
Posts: 350
in your form in validation.xml change
<form name="/myPage">

to
<form name="myForm">


Rick Hightower is CTO of Mammatus which focuses on Cloud Computing, EC2, etc. Rick is invovled in Java CDI and Java EE as well. linkedin,twitter,blog
Rick Hightower
Author
Ranch Hand

Joined: Feb 20, 2002
Posts: 350
Professional Struts (a book) has very good step-by-step instructions how to use the Validator framework with really good descriptions.
Mallika R Kumar
Ranch Hand

Joined: Jan 21, 2004
Posts: 38
Hi Rick,
I replaced "/myPage" with "myForm" in the validation.xml file's form name tag, but still I get the same result. The validations are just bypassed, and I can get to menu.jsp when I hit the submit button on myPage.jsp. I also tried making the Dynamic form bean a class of type org.apache.struts.validator.DynaValidatorForm instead of DynaValidatorActionForm, but did not see any difference in the outcome.
Am I missing something here ?
Thanks,
Mallika.
 
jQuery in Action, 2nd edition
 
subject: Struts Validation not working
 
Similar Threads
Struts Validator Framework error
Error using Struts Validator
STRUTS: client-side validation in jsp using DynaValidatorForm
Struts Validator With Modules
Struts Validation not working