Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use c:set to set a non-string value

Whenever doing <c:set var="name" value="1"/>, #{name} is always a String as evidenced by #{name.class}.

Is there any way to in a JSF/Facelets context to set a scoped attribute that is an Integer or Long literal value?

like image 553
GreenieMeanie Avatar asked Mar 17 '10 17:03

GreenieMeanie


Video Answer


1 Answers

EL has Automatic Type Conversion. This article has some good information. However, the short of it is that you shouldn't care. You should be able to do things like the following as long as param.month is, in fact, an Integer.

<c:set var="myInteger" value="${param.month}"/>
<p>
The value of myInteger is:<c:out value="${myInteger}"/>
Perform a multiplication operation to show that the type is correct:
<c:out value="${myInteger *2}"/>
like image 158
Randy Simon Avatar answered Nov 15 '22 07:11

Randy Simon