Validator - PowerPoint PPT Presentation

1 / 9
About This Presentation
Title:

Validator

Description:

Validator. A plugin for struts 1.1 ... Using commons-validator outside of struts. Decent resources ... Validator Lab. We are going to make a new form that ... – PowerPoint PPT presentation

Number of Views:25
Avg rating:3.0/5.0
Slides: 10
Provided by: mik53
Category:

less

Transcript and Presenter's Notes

Title: Validator


1
Validator
  • A plugin for struts 1.1
  • Provides a fairly complete list of pre-written
    validations for forms
  • Extensible to write your own validations
  • By default it does server-side validation but it
    can also handle client side javascript
  • Can handle wizard web pages

2
Basic idea
  • In an external XML file..
  • You declare a form
  • Then you declare a field
  • Then you state which validations to apply
  • Then it all works

3
How to implement
  • Your ActionForms now extend ValidatorForm
  • You need to put entries in validation.xml
  • Declare the formbean
  • Declare the field
  • Declare the validations
  • Enter the error message in application.properties

4
Types of validation available
  • Required
  • Requiredif
  • Minlength
  • Maxlength
  • Mask
  • Byte
  • Short
  • Integer
  • Long
  • Float
  • Double
  • Date
  • intRange
  • floatRange
  • Credit card
  • Email

5
Abilities we wont cover
  • Enabling javascript
  • Writing your own custom validator
  • Multi-page forms (wizards)
  • Multi-lingual error messages
  • Using commons-validator outside of struts

6
Decent resources
  • http//jakarta.apache.org/struts/userGuide/dev_val
    idator.html (talks about javascript,
    Internationalization, and custom validators
  • http//jakarta.apache.org/struts/userGuide/buildin
    g_view.html (very basic)
  • http//www.manning.com/husted/chap12.pdf (sample
    chapter from struts in action)
  • http//javaboutique.internet.com/resources/books/s
    trutsAction/struts6_1.html (good for how to use
    each type of validator)
  • The best is to take the example webapp apart

7
Validator Lab
  • We are going to make a new form that gathers
    information from the user
  • New ValidatorForm
  • New Action
  • New pieces to application.properties
  • New JSP pages
  • Modify struts-config

8
Quick intro to Ant
  • Basically an xml file that species what to do
    during the process of making an application
  • Everything is in a file called build.xml
  • Can do almost anything you want
  • Checkout from VCS
  • Compile your entire project
  • Start and stop tomcat
  • Make a deploy file
  • Filter and replace in your files
  • SCP or SFTP between machines
  • Validate your xml
  • Many many more

9
How to use ant
  • You define properties
  • You define tasks
  • They can depend on other tasks
  • They can be executed by themselves
  • Then you run it
  • The default task
  • Specific task
  • In netbeans, you can just press f6 while the
    build.xml is highlighted
  • Should we look at it together?
Write a Comment
User Comments (0)
About PowerShow.com