JSF号码验证 [英] JSF Number Validation
本文介绍了JSF号码验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
JSF中是否有任何内置的数字验证器标记来检查在h:inputext
字段中输入的输入是否为数字?
Is there any inbuilt number validator tag in JSF that checks whether an input entered in h:inputext
field is a number?
第一个问题已回答.编辑以解释下一个问题:
The first question was answered. Edited to explain the next problem:
<h:inputText id="maxrecs" value="#{simpleBean.numRecords}" required="false" maxlength="4" >
<f:convertNumber longOnly="true"/>
</h:inputText>
后备豆
private long numRecords = null;
如果在后备bean中使用String或Integer对象,则未设置值.现在,当我使用基本int时,屏幕上将打印0.我希望屏幕为空.
If I use String or Integer object in the backing bean , value is not being set. Now when I use primitive int, 0 is being printed on the screen. I would like the screen to be empty.
推荐答案
您可以使用f:convertNumber
(使用integerOnly
属性).
You can use f:convertNumber
(use the integerOnly
attribute).
您可以在此处获得更多信息.
You can get more information here.
这篇关于JSF号码验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文