Link to home
Start Free TrialLog in
Avatar of aturetsky
aturetsky

asked on

null list in c:forEach prevents even the static html outside the loop from rendering

I've got following code in my jsp:
            <c:forEach var="update"
                  items="${rfqAnalysisFormBean.rfq.rfqUpdateHistoryList}"
                  varStatus="indexStatus">
                  <c:if test="${indexStatus.count % 2 == 1}">
                        <tr border="0" cellpadding="0" cellspacing="0" class="bg_grey">
                  </c:if>


                  <c:if test="${indexStatus.count % 2 == 0}">
                        <tr border="0" cellpadding="0" cellspacing="0">
                  </c:if>
                  <td height="17" align="center">
                  <div align="left">&nbsp;On&nbsp;<fmt:formatDate
                        value="${update.updateDate}" pattern="MM/dd/yyyy" />&nbsp; the date
                  was changed to <fmt:formatDate value="${update.bidCloseDate}"
                        pattern="MM/dd/yyyy" />&nbsp;because <c:out
                        value="${update.updateComment}" /></div>
                  </td>
                  </tr>
            </c:forEach>

Now, if rfqAnalysisFormBean.rfq.rfqUpdateHistoryList is null, not only do the elements inside the loop not render (which is correct), but the rest of the page, including the static html elements do not render as well.  So I said, ok, let me put an if clause before the loop to  check for null list (see below), hoping it should solve my problem, but that didn't help either.  What do you think is happening?

            <c:if test="${rfqAnalysisFormBean.rfq.rfqUpdateHistoryList != null}">
            <c:forEach var="update"
                  items="${rfqAnalysisFormBean.rfq.rfqUpdateHistoryList}"
                  varStatus="indexStatus">
                  <c:if test="${indexStatus.count % 2 == 1}">
                        <tr border="0" cellpadding="0" cellspacing="0" class="bg_grey">
                  </c:if>


                  <c:if test="${indexStatus.count % 2 == 0}">
                        <tr border="0" cellpadding="0" cellspacing="0">
                  </c:if>
                  <td height="17" align="center">
                  <div align="left">&nbsp;On&nbsp;<fmt:formatDate
                        value="${update.updateDate}" pattern="MM/dd/yyyy" />&nbsp; the date
                  was changed to <fmt:formatDate value="${update.bidCloseDate}"
                        pattern="MM/dd/yyyy" />&nbsp;because <c:out
                        value="${update.updateComment}" /></div>
                  </td>
                  </tr>
            </c:forEach>
            </c:if>
SOLUTION
Avatar of suprapto45
suprapto45
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of aturetsky
aturetsky

ASKER

strangely, not just the ones after the closing </c:forEach> but even ones before the opening <c:forEach>
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I've been working urgently on something else - but I'll check this out soon and let you know what happens
Thanks.
hmm, for some strange reason - I tried recreating the problem, but now everything except for the list shows up - as is appropriate - so  I can no longer replicate the symptoms - manuel_m's suggestion was useful in other regards, so I'll mark it as the accepted answer, while giving suprapto45 points for participation