Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSF Number Validation

Tags:

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.

like image 674
Punter Vicky Avatar asked Nov 16 '11 08:11

Punter Vicky


People also ask

Which validator tag do you use on a float value?

f:validateDoubleRange tag is used to validate a value to a range of float values.


1 Answers

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

You can get more information here.

like image 97
Khizar Avatar answered Oct 03 '22 00:10

Khizar