• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts validation not happening

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 558
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is not struts forum
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try setting the page number in the JSP like this:

Also, "isrequired" should be "required" and "validateEmail" should be "email".
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The ActionForm should extend the ValidatorForm .
Then you should write the error messages what you want to display in message.properties.
reply
    Bookmark Topic Watch Topic
  • New Topic