JSF Number Validation

jsf

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>

Backing Bean

private long numRecords = null;

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.

Best Answer

You can use f:convertNumber (use the integerOnly attribute).

You can get more information here.

Related Topic