Apache Commons Validator

陈刚洁
2023-12-01
  •  
    • 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

NameDescriptionType
argA value that's plugged into the message String
clientIf true, validation is performed on the client String
datePatternStrictA date pattern using syntax defined in java.text.SimpleDateFormat String
maskA regular expression to which the value must conform String
maxThe maximum valid value String
maxlengthThe maximum valid length of the field String
messageA message displayed when validation fails String
minThe minimum valid value String
minlengthThe minimum valid length of the field String
serverIf true, validation is performed on the server String
typeThe 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

 

  

 

 类似资料:

相关阅读

相关文章

相关问答