codecamp

JSF 校验器标签

JSF教程 - JSF校验器标签


JSF有buildin验证器来验证其UI组件。

验证器标签可以验证字段的长度,输入类型可以是自定义对象。

我们必须在html节点中使用以下URI的名称空间来包括验证器标签。

<html 
   xmlns="http://www.w3.org/1999/xhtml" 
   xmlns:f="http://java.sun.com/jsf/core">
...

验证程序标签

下表在JSF 2.0中有重要的Validator标签:

标签描述
f:validateLength验证字符串的长度
f:validateLongRange验证数值的范围
f:validateDoubleRange验证浮点值的范围
f:validateRegex使用给定的正则表达式验证JSF组件。
Custom Validator创建自定义验证器


JSF 自定义转换器示例
JSF 验证字符串长度示例
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }