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>
LVL 1
aturetskyAsked:
Who is Participating?
 
manuel_mConnect With a Mentor Commented:
instead of using  <c:if test="${rfqAnalysisFormBean.rfq.rfqUpdateHistoryList != null}">

try this:  <c:if test="${not empty rfqAnalysisFormBean.rfq.rfqUpdateHistoryList}">

not empty will check if your list contains any data :)

would also like to see the error message...

greetz
manuel
0
 
suprapto45Connect With a Mentor Commented:
Hi,

Do you mean that if your rfqAnalysisFormBean.rfq.rfqUpdateHistoryList is null then the HTML codes after </c:forEach> is not executed. Am I right?

regards
Dave
0
 
aturetskyAuthor Commented:
strangely, not just the ones after the closing </c:forEach> but even ones before the opening <c:forEach>
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
suprapto45Connect With a Mentor Commented:
Hi aturetsky,

I think that you have some exceptions in your app server console. Can you post the error message here? My assumption is that your screen does not display anything, correct?

Regards
Dave
0
 
aturetskyAuthor Commented:
I've been working urgently on something else - but I'll check this out soon and let you know what happens
Thanks.
0
 
aturetskyAuthor Commented:
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
0
All Courses

From novice to tech pro — start learning today.