How to pass an Integer constant

Viewed 8282

I have <f:attribute name="someInt" value="#{1}"/> which is retrieved from component in faces Converter. I found that expression "#{1}" evaluates to Long instead of Integer (was hoping there is something like #{1} for an int and #{1L} for a long but it doesn't work that way). It is possible to pass an Integer without emplyoing bean e.g. #{bean.castToInt(1)}? Do I have to simply use Long for an integer numbers?

1 Answers

You can use the java.lang.Long.intValue() method for this:

<f:attribute name="someInt" value="#{(1).intValue()}"/>
Related