Apache Commons Validator

来源:互联网 发布:c语言小写字母转大写 编辑:程序博客网 时间:2024/05/20 08:45
  •  
    • Add an onsubmit attribute to your h:form tag that calls the JavaScript validation function generated by s:validatorScript.
    • Add Commons validators to JSF input components with s:commonsValidator and, optionally, s:validatorVar.
    • Add an s:validatorScript tag at the end of the h:form tag's body.

Apache Commons Validator对JSF页面验证提供了良好的支持和补充,以下为使用小结:

 

使用范例

 

Services Provided

Shale provides three JSP tags that let you use the Commons Validator: s:commonsValidator, s:validatorVar, and s:validatorScript. The first two lets you attach a commons validator to a JSF input component and the third generates JavaScript validation code for validating each JSF component that has one or more Commons validators in a particular form. You can attach as many Commons validators to a single JSF input component as you wish.

 

commonsValidator Attributes

NameDescriptionTypeargA value that's plugged into the message StringclientIf true, validation is performed on the client StringdatePatternStrictA date pattern using syntax defined in java.text.SimpleDateFormat StringmaskA regular expression to which the value must conform StringmaxThe maximum valid value StringmaxlengthThe maximum valid length of the field StringmessageA message displayed when validation fails StringminThe minimum valid value StringminlengthThe minimum valid length of the field StringserverIf true, validation is performed on the server StringtypeThe type of validator associated with this tag String

 

 

type支持类型

 

Minlength  maxlength  creditCard   required    integer  intRange  

 

long  float  floatRange  double  doubleRange  Date  email 

 

mask  Byte  short  url

 

includeJavaScriptUtilities 

 

 

 文摘来源: 

1:http://shale.apache.org/shale-core/tagreference.html#commonsValidator

 

2:http://shale.apache.org/1.0.4/shale-validator/index.html

 

  

 

原创粉丝点击