I m using lazy loading with pagination in a dataTable, and works fine. The problem is that I have an advanced search functionality in the same html page, and when I click on the search button, I want my dataTable to be updated according to the values I entered in the advanced search fields (this functionality is implemented at DaoFactory.getDocumentoDao().buscarLazy(first, pageSize)
,
the code is below. But the update attribute at my button doesn t seem to do anything becouse the load method of the lazy model is not called. So the question is: can I somehow call the load method of the lazy model from outside of the model in order to have my dataTable updated?
表格M:
<h:form id="frmCli">
<p:commandButton value="Buscar"
update="frmCli:panelResultadosDoc"/>
<h:panelGroup id="panelResultadosDoc">
<div class="dataTable">
<p:dataTable id="documentos"
value="#{documentoBuscadorBean.lazyModel}"
lazy="true"
var="varDocBean"
paginator="true"
paginatorPosition="bottom"
paginatorAlwaysVisible="false"
rows="5">
<p:column>
<f:facet name="header">Código</f:facet>
<h:outputText value="#{varDocBean.documento.id}"/>
</p:column>
</p:dataTable>
</div>
</h:panelGroup>
</h:form>
有待于:
@ManagedBean
@SessionScoped
public class DocumentoBuscadorBean {
private LazyDataModel<DocumentoBean> lazyModel;
@SuppressWarnings("serial")
public DocumentoBuscadorBean() {
lazyModel = new LazyDataModel<DocumentoBean>() {
public List<DocumentoBean> load(int first, int pageSize, String sortField, boolean sortOrder, Map<String,String> filters) {
List<DocumentoBean> lazyListDocumentos = new ArrayList<DocumentoBean>();
try {
lazyListDocumentos = DaoFactory.getDocumentoDao().buscarLazy(first, pageSize);
} catch (DocumentoException e) {
e.printStackTrace();
}
return lazyListDocumentos;
}
};
lazyModel.setRowCount(DaoFactory.getDocumentoDao().rowCount());
lazyModel.setPageSize(5);
}
public LazyDataModel<DocumentoBean> getLazyModel() {
return lazyModel;
}
}