Whenever doing <c:set var="emp"><cq:text property="empid" /></c:set> is always giving me string. But var suppose to return 'int'. Is there any any to get 'int' instead of 'string'
Thanks
is always giving me string. But var suppose to return 'int'. Is there any any to " />
On
You can use the <fmt:parseNumber> tag, which is already available in CQ5 (the <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> library is referenced by global.jsp) and which is a good thing to do to avoid scriptlets. This example is detailed at http://www.tutorialspoint.com/jsp/jstl_format_parsenumber_tag.htm:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
<title>JSTL fmt:parseNumber Tag</title>
</head>
<body>
<h3>Number Parsing:</h3>
<c:set var="balance" value="1250003.350" />
<fmt:parseNumber var="i" type="number" value="${balance}" />
<p>Parsed Number (1) : <c:out value="${i}" /></p>
<fmt:parseNumber var="i" integerOnly="true"
type="number" value="${balance}" />
<p>Parsed Number (2) : <c:out value="${i}" /></p>
</body>
</html>
This would produce following result:
Number Parsing:
Parsed Number (1) : 1250003.35
Parsed Number (2) : 1250003
You are using the
<cq:text>tag which is per se a string. Try the following:If the property is a number in CRX this should return a number as well. Else you would need to use a scriptlet to read the property type safe: