[Tapestry5] 如何使校验器动态化
hxzon
2011-02-22
如何使校验器动态化
模板: <t:loop source="value" value="item" formState="ITERATION"> <t:label for="numCurrentReceive"/> <t:textfield value="item.numCurrentReceive" t:id="numCurrentReceive" label="current receive num" validate="xxx"/> </td> </tr> </t:loop> 其中 the t:textfield's validate 是动态的,但不知如何完成? 尝试下列方法: <t:textfield value="item.numCurrentReceive" t:id="numCurrentReceive" label="current receive num" validate="prop:item.validateString"/> and the item class add this method: public String getValidateString(){ return "required,max="+this.getNumUnReceiving(); } 失败,抛出异常:不能将String转为校验器: |
|
fantify
2011-02-23
试试通过FieldValidatorSource#createValidators(field, expression)返回FieldValidator对象
|
|
hxzon
2011-02-24
万分感谢,我原来也想用这个方法,但是以为有loop有多次循环,不知道createValidators(field, expression)的field该用哪个值,想多了。一解决,谢谢~~
|