primefaces Datatable update footer totals with filter – RequestContext Callback version

Posted: November 13, 2012 in web

xhtml: (be sure to use oncomplete not onsuccess)

                <f:facet name="footer">
                    <h:outputText value="#{bean.milesTotal}" id="milesTotal" />

<p:ajax  oncomplete="handleComplete(xhr, status, args)" event="filter" listener="#{bean.onFilter}"  />


public void onFilter(FilterEvent e) {
        List<Car> filteredCars = (List<Car>) e.getData();
        if (filteredCars != null) {
            milesTotal = service.getMilesSum(filteredCars);
        if (filteredCars == null && e.getFilters().size() == 0) {
	RequestContext rc = RequestContext.getCurrentInstance();
        rc.addCallbackParam("milesTotal", milesTotal);


function handleComplete(xhr, status, args){
  1. csaez says:

    i need the same but an disabled atributte for comandbutton

  2. Omar says:

    Good work man 🙂

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s