i'm trying to combine my LazyDataModel with a search form so that whenever search criteria changes its result gets reflected in a lazy laded data table.
my page
Code: Select all
<h:form prependId="false">
<h:inputText value="#{searchBean.name}" />
<h:commandButton value="Search" action="#{searchBean.search}"/>
<p:dataTable paginator="true" lazy="true" rows="10" var="item" value="#{searchBean.results}" id="resultTable">
<p:column headerText="Name" sortBy="#{item.name}" >#{item.name} /></p:column>
</p:dataTable>
</h:form>
Code: Select all
@ManagedBean
@ViewScoped
public class SearchBean{
private LazyDataModel<Model> results;
private String name;
public SearchBean(){
results = new SearchsLazyLoader ();
}
private final class SearchsLazyLoader extends LazyDataModel<Model> {
public List<Model> load(int first, int pageSize, String sortField, boolean sortOrder,
Map<String, String> filters)
{
return mydao.findModelsByName(name); //here i simply pass name param from a bean to dao
}
}
public final String search(){
results = new SearchsLazyLoader ();
results.setRowCount(10); //for simplicity i always return 10 rows
}
public void doAjax(){ //i used this method for p:commandButton tag in my second test
search();
}
... //getter and setters code follows
}
1. the first time i hit "search" button data are loaded from dao and table gets populated accordingly
2. changing search criteria (updating search name param) doesn't update table (using debugger i can see that there isn't any call to load method in SearchLazyLoader)
3. doing sort operation on a name column updates table and there is a call to SearchLazyLoader
i found this issue http://code.google.com/p/primefaces/iss ... il?id=1356 and tried to follow all suggested steps but with no luck (i have no idea why the issue's status is "Cant replicate" as one needs just a few lines of code to see that the problem really exist) with the exception that case 2 on my previous list has changed i.e. my SearchLazyLoader gets called but for some reason table doesn't get updated
i'd like to add that the same results i get when used with p:ajax tags i.e.
Code: Select all
<p:commandButton value="Search" actionListener="#{searchBean.doAjax}" process="@form" update="resultTable">
i've been using primefaces 2.2.rc1