Saving global filter primefaces when using poll

Posted: November 12, 2012 in web

Had this working using filter event on p ajax. See complete code below.

xhtml:

	<h:panelGroup id="main">
		<p:dataTable id="reportTable" var="car" value="#{bean.cars}" widgetVar="reportTable">
			<f:facet name="header">  
                Cars
                <p:inputText id="globalFilter" styleClass="globalFilter" value="#{cars.filterGlobal}" onkeyup="reportTable.filter()" />
                <p:watermark for="globalFilter" value="Search with a keyword" />
            </f:facet>
			<p:column filterBy="#{car.name}"
				headerText="Name" filterMatchMode="startsWith">
				<h:outputText value="#{car.name}" />
			</p:column>

			<p:ajax  oncomplete="reportTable.filter();" event="filter" 
				update=":main"  />
		</p:dataTable>
	</h:panelGroup>

	<p:poll interval="30" update=":main" />

Bean:



@Named("bean")
@ViewScoped
public class Bean implements Serializable {

    private static final long serialVersionUID = -6519881882062309049L;

    private String filterGlobal;

    ...
	
    public String getReportFilterGlobal() {
        return reportFilterGlobal;
    }

    public void setReportFilterGlobal(String reportFilterGlobal) {
        this.reportFilterGlobal = reportFilterGlobal;
    }
}
Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s