我在dataTable中使用带有分页的延迟加载,并且工作正常。问题是我在同一个html页面中具有高级搜索功能,并且当我单击搜索按钮时,我希望我的dataTable根据我在高级搜索字段中输入的值进行更新(此功能在,代码如下。但是我按钮上的update属性似乎没有任何作用,因为未调用惰性模型的load方法。所以问题是:我可以以某种方式从模型外部调用惰性模型的load方法以更新我的dataTable吗?形成:<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@SessionScopedpublic 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; }} (adsbygoogle = window.adsbygoogle || []).push({}); 最佳答案 如果我不缺少任何内容,则可以使用操作:<p:commandButton value="Buscar" action="#{documentoBuscadorBean.lazyModel.load(0,10,...)}" process="@form" update="frmCli:panelResultadosDoc"/>最好添加无参数的加载版本,以免在视图中混用逻辑。如果由于某种原因不能使用EL 2.2,这甚至是强制性的(不过,我强烈建议您使用EL 2.2,这样可以节省很多f:param处理)。 (adsbygoogle = window.adsbygoogle || []).push({});
10-04 20:35