How to reset the row index for p: dataList / p: dataTable on every page?

Below is an example <p:dataList>

.

<p:dataList var="row"
            value="#{bean}"
            first="0"
            rows="10"
            rowIndexVar="listRowIndex"
            widgetVar="dataListUIWidget"
            paginator="true"
            paginatorAlwaysVisible="false"
            lazy="true">

    <h:outputText value="#{listRowIndex+1}"/>

</p:dataList>

      

This will show the row index for each row starting at 1 ( listRowIndex+1

).

How can I reset listRowIndex

on every page so that it starts at 1 on every page change (i.e. it should start at 1 on every page)?

+3


source to share


2 answers


Store the value first

in the bean view and change the text output to



<h:outputText value="#{listRowIndex - bean.first + 1}"/>

      

+3


source


Clear the Beans data by creating a new instance so that the data is reset or you can change the scope of the managedBean



+2


source