JSF + Primefaces update component when switching pagination

Asked

Viewed 631 times

0

    <p:dataList paginator="true" value="{bean.lista}"
                        var="lista">
    </:dataList>

<h:outputText value="qualquerCoisa" id="teste"/>

How do I update outputText 'test' every time the dataList page changes? , example paging 1,2,3,4[...] when the user changes from page 1 to page 2 update the 'test' component, when to switch to another page update again? The component must be outside the dataList or datatable and has to be when changing pagination, without buttons or something like.

1 answer

1


follows an example:

<p:dataTable var="variavel" paginator="true" rows="1" value="#{myBean.list}">
  <p:ajax event="page" update="buttons" listener="#{myBean.update}" />
  ...
</p:dataTable>

here’s the method that will update your guy:

public void update(PageEvent event) {
  int var = event.getPage();
  ...
  (aqui você atualiza a variavel do seu componente)
  ...
}
  • Only with <p:ajax Event="page" update="Buttons" /> already worked as I wanted, we also had to change the <h:form> and put prependID="true". Thank you

Browser other questions tagged

You are not signed in. Login or sign up in order to post.