Get all updates of Java4s

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.


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 the Author .::

- Full Stack Java/J2EE & UI Web Developer
Founder of Java4s - Get It Yourself, A popular Java/J2EE Programming Blog, Love Java and UI frameworks.
You can sign-up for the Email Newsletter for your daily dose of Java tutorials.


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


By posting your answer, you agree to our comments policy.
What would you like to learn today?
Browse these popular technologies
Spring-Boot-tutorials Hibernate tutorials Spring tutorials Struts tutorials Servlets tutorials Ajax tutorials Log4j tutorials jQuery tutorials Json tutorials Core Java tutorials Web Services tutorials AngularJs tutorials
Most Recent Tutorials
Hibernate_Logo Hibernate Recent Posts Spring_Logo Spring Recent Posts Struts_Logo Struts Recent Posts
Contact | About Us | Privacy Policy | Advertise With Us

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