2

I'm using primefaces 3.4 (old one I know, but can't upgrade atm) , I know that in primefaces 5 my issue is resolved (but I really can't upgrade atm)

When using lazy / non lazy loading datatable with pagination I encounter the following issues,

1) ajax inputs (inside <p:dataTable) are not firing after pagination (page > 1)

2) element states (<h:selectBooleanCheckbox) are not reflected upon form submitting (even though I do see them being sent to server)

Any idea whats causing this misbehavior of primefaces / how to track it down / how can it be fixed in the 3.4 version?

My guess it has something to do with the following BalusC answer commandLink/commandButton/ajax backing bean action/listener method not invoked (N#4)

Community
  • 1
  • 1
Daniel
  • 36,833
  • 10
  • 119
  • 200

1 Answers1

0

For now I solved it with the following trick:

<p:ajax event="page" listener="#{myBean.detectPageEvent}" oncomplete="updateModel()"></p:ajax>

where the content of the bean detectPageEvent method looks like this:

public void detectPageEvent(PageEvent ev) {
    //SET page number
    ((LazyDeviceDataModel) lazyModel).setPageNumber(ev.getPage());
}

where the content of the js updateModel function is:

setTimeout(function () {
    $('#table-refresh-after-page').click();
}, 10); 

and in the xhtml page I have added the following

<h:commandButton id="table-refresh-after-page"
    styleClass="hide" action="#{myBean.updatePageNumber}">
    <f:ajax execute="@form" render="@form"></f:ajax>
</h:commandButton>

where the updatePageNumber method looks like this

public void updatePageNumber() {
    DataTable dataTable = (DataTable) FacesContext.getCurrentInstance().getViewRoot()
            .findComponent("my-form:my-table");
    dataTable.setFirst(((LazyDeviceDataModel) lazyModel).getPageNumber() * 10);
}

As I said before : My guess it has something to do with the following BalusC answer [commandLink/commandButton/ajax backing bean action/listener method not invoked][1] (N#4)

Daniel
  • 36,833
  • 10
  • 119
  • 200