0 Replies Latest reply on Jul 25, 2015 1:33 AM by omid pourhadi

    Seam Search duplicates query

    omid pourhadi Apprentice

      Hi,

       

      I created a list page using seam-gen with a simple inputText search as folllow.

       

      CustomersList.xhtml

       

      <h:form id="customersSearch" styleClass="edit">
                <s:decorate template="layout/display.xhtml">
                      <ui:define name="label">Cname</ui:define>
                      <h:inputText id="cname" value="#{customersList.customers.cname}"/>
                  </s:decorate>
                  <h:commandButton id="search" value="Search" action="/CustomersList.xhtml"/>
      </h:form>
      <h:form> // this prevents running query twice
      <rich:dataTable id="customersList"
                      var="_customers"
                    value="#{customersList.resultList}"
                 rendered="#{not empty customersList.resultList}">
                <h:column>
                  <f:facet name="header">
                      Customer Name
                  </f:facet>
                  <h:outputText value="#{_customers.cname}"/>
              </h:column>
            <rich:column styleClass="action">
                  <f:facet name="header">Action</f:facet>
                  
                  <s:link view="/CustomersEdit.xhtml"
                         value="Edit"
                   propagation="none"
                            id="customersEdit"
                      rendered="#{empty from}">
                      <f:param name="customersId"
                              value="#{_customers.id}"/>
                  </s:link>
              </rich:column>
      </rich:dataTable>
      </h:form>
      //Paging and the rest 
      

       

      the problem is when I hit search button I can see in jboss log file that query runs twice.

       

      select
              customers0_.id as id1_,
              customers0_.cname as cname1_ 
          from
              public.customers customers0_ 
          where
              lower(customers0_.cname) like lower((?||'%')) limit ?
      09:49:45,882 INFO  [STDOUT] Hibernate: 
          select
              customers0_.id as id1_,
              customers0_.cname as cname1_ 
          from
              public.customers customers0_ 
          where
              lower(customers0_.cname) like lower((?||'%')) limit ?
      

       

      but after I put rich:dataTable in h:form the query runs once is this because of jsf or what ?

       

      I've used Seam 2.2 and 2.3/ Jboss 4.2/7 + richfaces 3.3.1GA.

       

      PS : customersList seam component is exactly what seam-gen generates