webwork的客户端javascript校验器和普通校验器

类别:Java 点击:0 评论:0 推荐:
下载请访问 http://forum.javaeye.com/viewtopic.php?t=9126&postdays=0&postorder=asc&start=0


 

WebWork2 扩展校验器使用说明

1.下载文件并解压

2.找到jscud_wwvalidators_1_??.jar,修改classpath或者复制到对应路径

3.复制checkform.js文件到你的项目,然后引用

  引用有2种方法

  I: 直接在你的程序中引用checkform.js (注意修改路径)

  <script language="javascript" src="checkform.js"></script>

   

  II: 修改/重载 form-close.vm,引用或者包含checkform.js也可.请参考webwork的文档.

  例如加入: #parse("/template/XXX/checkform.js")  

 或者
  <script language="javascript" src="$req.contextPath/js/checkform.js"></script>
#parse("/template/simple/form.vm")
<table class="wwFormTable">

4.修改你的validators.xml 

  注意:对于多语言字符串长度校验器,对于一个项目,同时只能使用其中一个,根据你的存储情况设置,当然在安装时也可设置.(这是一个不方便的地方,但是可能也别无选择)

  参考test目录下的validators

5.修改校验文件XXXAction-validation.xml 或者 XXXAction-Alias-validation.xml

  参考test目录下的TestAction-doAdd-validation.xml


 

Validator List

Server Side Validator Client JavaScript Validator Desc Parameter Memo RequiredStringValidator JSRequiredStringValidator Required String Validator trim JavaScript deal trim StringLengthFieldValidator JSStringLengthFieldValidator String Length Validator trim minLength maxLength   IntegerValidator JSIntegerValidator Int Validaotr maxnum minnum datatype JavaScript check validity FloatValidator JSFloatValidator float validator maxnum minnum   LongValidator - long validator maxnum minnum   EmailValidator JSEmailValidator Email validator - JavaScript Change URLValidator JSURLValidator URL validator -   ABCLetterValidator JSABCLetterValidator 26 Letters Validator -   BaseWordValidator JSBaseWordValidator Base Ascii Letter Validator -   CustomDataRegExpValidator JSCustomDataRegExpValidator Custom Reg Express Validator regexp                      

String Storage Length Validator One2OneSaveStringLengthFieldValidator JSOne2OneSaveStringLengthFieldValidator One->One trim minLength maxLength   One2TwoSaveStringLengthFieldValidator JSOne2TwoSaveStringLengthFieldValidator One->Two trim minLength maxLength   One2ThreeSaveStringLengthFieldValidator JSOne2ThreeSaveStringLengthFieldValidator One->Three trim minLength maxLength            

Blue Class : webwork class,not belong this lib.

Red Class: webwork exist same class,this lib improve it or change it.

本文地址:http://com.8s8s.com/it/it12972.htm