Frameworks| Hibernate| Struts| JSF| JavaFX| Ajax| Spring| DOJO| JDO| iBatis| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials:
 

Software Solutions and Services
 

 
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments
 
Struts 2 Validation 
 

User input validations are integral part of any web application.

 

Struts 2 Validation

                         

User input validations are integral part of any web application. With the release of Struts 2, validation are now much easier and robust. Struts 2 support Ajax based and even server side validations. Struts 2.0 action relies on the XWork validation framework. The XWork framework runs the validation rules before executing the action. Struts 2 also provides the facility to define validation rules in your action class using Java 5 annotations. 

  1. Struts 2 Validation (Int Validator)
    Struts 2 Framework provides in-built validation functions to validate user inputs. These validation functions are sufficient for any normal web application.

  2. Struts 2 RequiredString validator
    This section discusses RequiredString validator of Struts 2 framework. RequiredStringValidator checks the String field is non-null and its  length is > 0. (i.e. it isn't "").
       
  3. Struts 2 double validator
    The Double validator of Struts 2 Framework checks if the given input is double or not. If the input is not double, it generates the error message. Double validator can also be used to check the input range.
       
  4. Struts 2 Date Validator
    The Date validator in the Struts 2 Framework checks whether the supplied date lies within a specific range or not. If the value supplied does not lie in the specified range, it generates an error message.
            
  5. Struts 2 E-mail Validator
    The email validator in  Struts 2 Framework checks whether a given String field is empty or not and contains a valid email address or not. If the entered value does not match with the email type, then the e-mail validator generates an error message. 
          
  6. Struts 2 Url Validator
    The URLValidator of Struts 2 Framework checks whether the String contained within the given field is a valid URL or not. If the entered value is not a valid URL, it generates an error message.
           
  7. Validations using Struts 2 Annotations
    In this section we are going to validate our login application using Annotations in Action class. Our current login application does not validate the user against the database. Instead login name and passwords are validated against the hardcode values (User: Admin and Password: Admin) in the action class.

                         

» View all related tutorials
Related Tags: c validation struts io release id ie with e it li no as m tr valid bus ase rel s

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

1 comments so far (
post your own) View All Comments Latest 10 Comments:

Is there some way to validate whether two fields are the same in Struts 2. I know there was a validwhen validator type in Struts 1, but I can't seem to find it anymore.

Posted by Jon on Sunday, 01.20.08 @ 02:03am | #45631

Training Courses
Tell A Friend
Your Friend Name
Website Designing Services
 
Web Designing Packages From $150!
 
Website Designing Company Web Hosting
 
Website Designing Quotation
 
Search Tutorials:

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.