Get all updates of Java4s
Follow Us: Email Newsletter

How To Apply Multiple XML Validations On Same Field In Struts 2

Struts » On Oct 25, 2011 { 1 Comment } By Sivateja

Hi there, this is very important concept in real time, applying multiple validation rules on same field.  For example we have Email filed and we would like to apply 2 validations to this field like email, requiredstring. [ hey these 2 are rules right,  just go back and check the previous concept if not clear :-) ]

So we want users to enter email id which contains only string value.

Actually by default if one rule, suppose requiredstring failed no need to check email rule right, but by default struts 2 will verify email rule also.  So to avoid this, we need to write short-circuit=”true”.  What am saying if we apply 5 rules to one filed then if 1 rule is failed there is no need to check others right… :-) that what am saying hope it make sense.

Example:

Note: If first rule [ requiredstring ] failed, then struts 2 will not verify email rule as we given short-cricuit=”true”.  Same concept even if you apply 1000 rules hah  :-) and that’s it nothing is more than this.

You can check practically in the next example….!!!!!!

You Might Also Like

  ♦ About Author ♦

Java4s_Author
sivateja@java4s.com
Full Stack( Java/J2EE & UI/UX ) Developer and founder of Java4s - Get It Yourself, A popular Java/J2EE Programming Blog. Sign-up for the Email Newsletter for your daily dose of Java tutorials.

Comments

One Response to “How To Apply Multiple XML Validations On Same Field In Struts 2”
  1. Jagannath says:

    Hi, there are 2 file browse buttons and 3 submit on jsp page like “View Photo”,”view Signature” and “Submit”. I want to apply validation on submit button only,photo and signature must be used to display images after uploading. Other problem is if I click on a any button file path is removed how can I fix it?

    Thanks and Regards,
    Jagannath Kale

Name*
Mail*
Website



By posting your answer, you agree to our comments policy.
What would you like to learn today?
Browse these popular technologies
Hibernate spring struts Servlets ajax Log4j jQuery Json Core Java Web Services AngularJs
Most Recent Tutorials
Hibernate_Logo Hibernate Recent Posts Spring_Logo Spring Recent Posts Struts_Logo Struts Recent Posts
Useful Links Current & UpComing Tutorials
Upcoming
  Web Services [ SOAP ], JSP
Contact | About Us | Privacy Policy | Advertise With Us

© 2010 - 2016 Java4s - Get It Yourself.
The content is copyrighted to Sivateja Kandula and may not be reproduced on other websites.