Apache Commons Validator

  •  
    • 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
arg A value that's plugged into the message String
client If true, validation is performed on the client String
datePatternStrict A date pattern using syntax defined in java.text.SimpleDateFormat String
mask A regular expression to which the value must conform String
max The maximum valid value String
maxlength The maximum valid length of the field String
message A message displayed when validation fails String
min The minimum valid value String
minlength The minimum valid length of the field String
server If true, validation is performed on the server String
type The 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

 

  

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章