如何在p:datatable的最后一行渲染p:commandButton?

时间:2013-02-23 13:54:19

标签: jsf primefaces datatable commandbutton

我只需要在<p:commandButton>的最后一个条目中呈现<p:datatable>。 考虑p:datatable是否有n个行表示我只在第n行渲染p:commandButton

2 个答案:

答案 0 :(得分:3)

我认为您最好使用<f:facet name="footer">

    <f:facet name="footer">  
        <p:commandButton/> 
    </f:facet>  

但如果你真的坚持最后一排......

尝试rowIndexVar,如下所示:

<p:dataTable value="#{myBean.myList}" rowIndexVar="rowIndex" var="item">
    <p:column>
        <p:commandButton rendered="#{(rowIndex+1) eq myBean.myList.size()}"/> 
    </p:column>
</p:dataTable>

答案 1 :(得分:2)

我不知道我是否正确使用了功能要求,但根据我的理解,您希望在表格底部添加一个commandButton,为此您可以使用以下内部数据表标记:

 <f:facet name="footer">
        <p:commandButton/>
 </f:facet>