Reputation: 3246
I just realize I can't set Integer value using JSTL set tag. I checked other post but didn't find related issue.
My JSTL code looks like
<c:set var="endIndex"
value="${fn:length(offeredService) - fn:length(serviceHistory) - 1} lt 0 ? ${fn:length(offeredService)} : ${fn:length(offeredService) - fn:length(serviceHistory) - 1}"/>
And error I am getting is
javax.el.ELException: Cannot convert -1 lt 0 ? 0 : -1 of type class java.lang.String to class java.lang.Integer
Whaat I am missing?
Upvotes: 0
Views: 651
Reputation: 490
Don't you just need to extend the braces so that the ternary operator actually evaluates?
<c:set var="endIndex"
value="${
(fn:length(offeredService) - fn:length(serviceHistory) - 1) < 0 ?
fn:length(offeredService)
: fn:length(offeredService) - fn:length(serviceHistory) - 1
}
"/>
As it is, the ternary operator is outside of an execution block so it is just treated like text.
Upvotes: 1