You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PrimeFaces 14中DataTable的rowsPerPageLabel属性不显示问题咨询

PrimeFaces 14中 <p:dataTable> 的 rowsPerPageLabel 属性问题解答

问题描述

将PrimeFaces从13版本升级至14版本后,<p:dataTable> 组件的 rowsPerPageLabel 属性设置后,分页器下拉框的标签文本不再显示。尝试通过 paginatorTemplate 直接添加标签文本,但显示效果不理想;而在13及更早版本中,通过该属性设置的标签显示正常。测试用最小代码示例如下:

<p:dataTable  value="#{testTableData.testLandliste}"
              var="item"
              paginator="true"
              rows="10"
              rowsPerPageTemplate="5,10,20"
              rowsPerPageLabel="Rows per page:"
              paginatorPosition="bottom"
              paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
              currentPageReportTemplate="{startRecord}-{endRecord} of {totalRecords} records">
        <p:column headerText="Name">
           <h:outputText value="#{item.nameEnglisch}" />
        </p:column>
</p:dataTable>

问题原因与解决方案

rowsPerPageLabel 属性并未被弃用,但PrimeFaces 14对分页器的渲染逻辑做了调整:在13及更早版本中,rowsPerPageLabel 的文本会自动附加到 {RowsPerPageDropdown} 元素前;而在14版本中,必须在 paginatorTemplate 中显式添加 {RowsPerPageLabel} 占位符,才能让设置的标签文本正常显示。

修改后的 paginatorTemplate 配置如下:

paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageLabel} {RowsPerPageDropdown}"

添加 {RowsPerPageLabel} 占位符后,rowsPerPageLabel 属性设置的文本就会正确显示在分页下拉框前方,效果与13版本一致。

内容的提问来源于stack exchange,提问作者K Akhil

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 02:52:05