2014-05-17 78 views
0

我只想在顯示行時纔有數據。我的代碼是:IF語句不適用於Primefaces DataTable

<p:dataTable id="comments" var="comment" 
     value="#{agencyBean.getCommentByAgency(agencyBean.tAgency)}" 
     paginator="true" > 

     <p:column> 
      #{comment.author.name} 
     </p:column> 

     <p:column> 
      <c:if test="${not empty comment.positiveComment}"> 
       <p:row> 
        <p:column> 
         <p:graphicImage library="images" name="positive.png" /> 
        </p:column> 
        <p:column> #{comment.positiveComment} </p:column> 
       </p:row> 
       <br /> 
      </c:if> 
     </p:column> 
    </p:dataTable> 

但不過我有數據,行不顯示。我怎樣才能實現這個邏輯?謝謝!

回答

3

嘗試把在<p:row>的標籤本身的條件表達式,通過使用其rendered屬性:

<p:column> 
    <p:row rendered="#{not empty comment.positiveComment}"> 
     <p:column> 
      <p:graphicImage library="images" name="positive.png" /> 
     </p:column> 
     <p:column> #{comment.positiveComment} </p:column> 
    </p:row> 
    <br /> 
</p:column> 
+0

你的意思是*嘗試使用'代替rendered'屬性*。 –

+0

是的,這就是我的意思。 – Omar

+0

非常感謝! – Tot

相關問題