English 中文(简体)
A. 从另一个构成部分获得的最新数据(使用zy装)
原标题:Update dataTable (using lazy loading) from another component

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;
   }

}
问题回答

如果我不遗漏一些东西,你只能采取行动:

<p:commandButton value="Buscar"
                 action="#{documentoBuscadorBean.lazyModel.load(0,10,...)}"
                 process="@form"
                 update="frmCli:panelResultadosDoc"/>

添加无参数的载荷,使您认为不会有混合逻辑。 如果你因某种原因不能使用EL 2.2(我强烈建议EL 2.2,尽管如此,可以节省很多细节:平行处理)。

意思是什么? <代码>varDocBean为DocumentoBean - soo为单证财产 Bean?

此外,Button的指挥系统没有做什么? 我只看到一个指挥Button,但没有的行动方法。

http://www.primefaces.org/showcase-labs/ui/datatable Lazy.jsf"rel=“nofollow”http://www.primefaces.org/showcase-labs/ui/datatable Lazy.jsf”





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签