0

I'm having trouble with JSP's <c:if test="">. <c:if test="true"> and <c:if test="false"> work as expected. But the following snippet doesn't:

<p:dataTable value="#{orderMB.allAdTypes}" var="ad">
  <c:if test="ad.isNotFullPage()">
   <p:column headerText="Type">
     <h:outputText value="#{ad.typeToString}" />
   </p:column>
  </c:if>
   <p:column headerText="Name">
     <h:outputText value="#{ad.name}" />
   </p:column>
</p:dataTable>

I only see one column; ad.isNotFullPage() is never called. I've tried all combinations of test="#{ad.isNotFullPage()}, test="${ad.isNotFullPage()}", test="#{ad.isNotFullPage} (this last in the hopes that ad.getIsNotFullPage() gets called.)

orderMB is a @ManagedBean @ViewScoped. orderMB.getAllAdTypes() returns List<AdType>. AdType is @Entity @Table(name = "ad_type").

This is running on Glassfish 3.1, JDK 1.7.

Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332
Leolo
  • 1,327
  • 9
  • 14
  • 1
    possible duplicate of [JSTL c:if inside a JSF h:dataTable](http://stackoverflow.com/questions/3442380/jstl-cif-inside-a-jsf-hdatatable) In a nutshell: `#{ad}` is not available at the moment JSTL runs. Use either JSF `rendered` attribute or move `isNotFullPate` to `#{orderMB}`. Think once again, it does not make any sense to be able to show/hide a *whole* column based on a condition of a *single* row. Wouldn't the very same condition apply on *all* rows then? Do it in the backing bean then. – BalusC May 31 '13 at 15:59
  • You are of course right. I'm writing my example like that so that I can see if `ad.getName()` is called. In reality, I want to exclude rows that are for full page ads. But now that you mention it, I might be doing that wrong. – Leolo May 31 '13 at 16:07

0 Answers0