Hi !

I have a slight problem.  I am building a paged results browser, and I
have a problem with my next action.

The root of the problem is because JSTL thinks that some values are
strings, and not numbers.

The code I am running is:
<fmt:formatNumber var="lastPageNo" value="${numberOfContacts / count}"
        minFractionDigits="0" maxFractionDigits="0"/>
<c:if test="${numberOfContacts le count}">
    <c:set var="lastPageNo" value="1"/>
</c:if>
<c:if test="${(numberOfContacts gt count) and ((numberOfContacts mod
count) ne 0)}">
    <c:set var="lastPageNo" value="${lastPageNo + 1}"/>
</c:if>

    pageNo:                <c:out value="${pageNo}"/>
    pageNo.class:          <c:out value="${pageNo.class}"/>
    lastPageNo:            <c:out value="${lastPageNo}"/>
    lastPageNo.class:      <c:out value="${lastPageNo.class}"/>
    pageNo lt lastPageNo:  <c:out value="${pageNo lt lastPageNo}"/>

This code does arithmetics on the numbers in some cases, and when these
run, everything is fine.  *But*, when the arithmetic operations do not
run, I get the following in my comment block:
    pageNo:                2
    pageNo.class:          class java.lang.String
    lastPageNo:            13
    lastPageNo.class:      class java.lang.String
    pageNo lt lastPageNo:  false

As you can see, JSTL considers both pageNo and lastPageNo to be strings.
I finally resolved my problem by switching to a choose, and adding an
otherwise block that adds 0 with lastPageNo, converting to a number.

All of this boils down to:  is there the equivalent of a Java cast in
JSTL ?  If there were, I could simply cast my pageNo and lastPageNo when
doing my tests, and everything would be fine.

Thanks for any help !
Fran�ois
Developer of Java Gui Builder
http://jgb.sourceforge.net/

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to