Question

is there any possibility to update other components AFTER filtering a lazy datatable?

<p:dataTable id="dataTable" value="#{NewsBean.items}" binding="#{NewsBean.items.dataTable}" lazy="true" filteredValue="#{NewsBean.filter}" var="item" paginator="true" rows="10"
            currentPageReportTemplate="(Displaying results {startRecord} - {endRecord} of {totalRecords})"
            paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
            rowsPerPageTemplate="10,20,50,100,200,500,1000" filterEvent="enter">

            ...

            <p:ajax event="filter" update="some_other_component" />

            ...

</p:dataTable>
<p:blockUI block="dataTable" trigger="dataTable" />

The specific problem is, that the filter event fires before my dataTable completes the lazy filtering and so the update event for the other component will be fired to early. So the component is not able to show filter specific content. Filtering again will show the result of one step before.

I found a solution by BalusC to use remote Command instead.

<p:ajax event="filter" oncomplete="updateFilterSelection()" />
<p:remoteCommand name="updateFilterSelection" update="some_other_component" />

But using this solution will end in an endless loading of my blockUI. Seems that oncomplete event isn't fired anymore.

Is there any solution?

I'm using primefaces 3.5.

Thanks

EDIT: I found a solution for me that works as expected:

<p:ajax event="filter" listener="#{some_Method}" update="some_other_component" />

some_Method does call a refresh, e.g a redirection on the current view. But I'm sure, that this creates a lot of overhead.

Was it helpful?

Solution

I struggled with a similar problem:

How to update the user interface after the Lazy Data is loaded.
There seems to be no Primefaces Event for this.

This is my solution:

  • Add this to your LazyDataModel load() method: RequestContext.getCurrentInstance().execute("updateUserInterface()");
  • In your view create a JavaScript function:
    function updateUserInterface() {
    // Commands to update the user interface
    }

OTHER TIPS

update=":#{p:component('size')}"

Here size is the id of outputText box.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top