2 Replies Latest reply on Jun 6, 2008 9:54 PM by Siarhei Dudzin

    Query parameter lost

    Jaime Martin Apprentice

      Hello,
      In a list page, when I fill a field with a value and press the search button, the displayed list doesn´t take into account the value. In fact, that value dissapear from the field.
      In the logs I notice that the value is indeed pased but later it fades away.


      This is the log. I find it really strange that pressing once the search button implies three Hibernate queries,
      and that the second one is the only one that receives the parameter (in my execution I´ve filled the field with the value LU


      17:20:57,953 INFO  [STDOUT] PRR_SEAM201GA - getRestrictions
      17:20:57,953 INFO  [STDOUT] PRR_SEAM201GA - getRestrictions - firmList.firm.firmCode: null
      17:20:57,953 INFO  [STDOUT] PRR_SEAM201GA - getRestrictions
      17:20:57,953 INFO  [STDOUT] PRR_SEAM201GA - getRestrictions - firmList.firm.firmCode: null
      17:20:57,953 INFO  [STDOUT] PRR_SEAM201GA - getRestrictions
      17:20:57,953 INFO  [STDOUT] PRR_SEAM201GA - getRestrictions - firmList.firm.firmCode: null
      17:20:58,109 INFO  [STDOUT] PRR_SEAM201GA - getRestrictions
      17:20:58,109 INFO  [STDOUT] PRR_SEAM201GA - getRestrictions - firmList.firm.firmCode: null
      17:20:58,109 INFO  [STDOUT] ---------------------------------
      17:20:58,125 INFO  [STDOUT] Hibernate: 
          select
              firm0_.firm_code as firm1_310_,
              firm0_.firm_ccy_code as firm3_310_,
              firm0_.firm_description as firm2_310_ 
          from
              prisk.dbo.FIRM firm0_
      17:20:58,250 INFO  [STDOUT] PRR_SEAM201GA - getRestrictions
      17:20:58,250 INFO  [STDOUT] PRR_SEAM201GA - getRestrictions - firmList.firm.firmCode: LU
      17:20:58,250 INFO  [STDOUT] PRR_SEAM201GA - getRestrictions
      17:20:58,250 INFO  [STDOUT] PRR_SEAM201GA - getRestrictions - firmList.firm.firmCode: LU
      17:20:58,625 INFO  [STDOUT] PRR_SEAM201GA - getRestrictions
      17:20:58,625 INFO  [STDOUT] PRR_SEAM201GA - getRestrictions - firmList.firm.firmCode: LU
      17:20:58,734 INFO  [STDOUT] Hibernate: 
          select
              firm0_.firm_code as firm1_310_,
              firm0_.firm_ccy_code as firm3_310_,
              firm0_.firm_description as firm2_310_ 
          from
              prisk.dbo.FIRM firm0_ 
          where
              lower(firm0_.firm_code) like (lower(?)+'%')
      17:20:59,281 INFO  [STDOUT] PRR_SEAM201GA - getRestrictions
      17:20:59,281 INFO  [STDOUT] PRR_SEAM201GA - getRestrictions - firmList.firm.firmCode: null
      17:20:59,281 INFO  [STDOUT] PRR_SEAM201GA - getRestrictions
      17:20:59,281 INFO  [STDOUT] PRR_SEAM201GA - getRestrictions - firmList.firm.firmCode: null
      17:20:59,281 INFO  [STDOUT] PRR_SEAM201GA - getRestrictions
      17:20:59,281 INFO  [STDOUT] PRR_SEAM201GA - getRestrictions - firmList.firm.firmCode: null
      17:20:59,625 INFO  [STDOUT] PRR_SEAM201GA - getRestrictions
      17:20:59,625 INFO  [STDOUT] PRR_SEAM201GA - getRestrictions - firmList.firm.firmCode: null
      17:20:59,625 INFO  [STDOUT] Hibernate: 
          select
              firm0_.firm_code as firm1_310_,
              firm0_.firm_ccy_code as firm3_310_,
              firm0_.firm_description as firm2_310_ 
          from
              prisk.dbo.FIRM firm0_
      
      



      This is the seam-gened FirmList class:



      @Name("firmList")
      public class FirmList extends EntityQuery {
      
           private static final String[] RESTRICTIONS = {
                     "lower(firm.firmCode) like concat(lower(#{firmList.firm.firmCode}),'%')",
                     "lower(firm.firmDescription) like concat(lower(#{firmList.firm.firmDescription}),'%')",};
      
           private Firm firm = new Firm();
      
           @Override
           public String getEjbql() {
                return "select firm from Firm firm";
           }
      
           @Override
           public Integer getMaxResults() {
                return 25;
           }
      
           public Firm getFirm() {
                return firm;
           }
      
           @Override
           public List<String> getRestrictions() {
                      System.out.println("PRR_SEAM201GA - getRestrictions");
                      if (this.firm != null) {
                          System.out.println("PRR_SEAM201GA - getRestrictions - firmList.firm.firmCode: "+this.firm.getFirmCode());                    
                      }
                      else {
                          System.out.println("PRR_SEAM201GA - getRestrictions - firmList.firm es null!!");
                      }
                return Arrays.asList(RESTRICTIONS);
           }
      
      }
      
      



      This is FirmList.page.xml


      <?xml version="1.0" encoding="UTF-8"?>
      <page xmlns="http://jboss.com/products/seam/pages"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.0.xsd">
            
         <param name="firstResult" value="#{firmList.firstResult}"/>
         <param name="order" value="#{firmList.order}"/>
         <param name="from"/>
         <param name="firmCode" value="#{firmList.firm.firmCode}"/>
         <param name="firmDescription" value="#{firmList.firm.firmDescription}"/>
      
      </page>
      



      And this is FirmList.xhtml



      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                                   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      
      
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                      xmlns:s="http://jboss.com/products/seam/taglib"
                      xmlns:ui="http://java.sun.com/jsf/facelets"
                      xmlns:f="http://java.sun.com/jsf/core"
                      xmlns:h="http://java.sun.com/jsf/html"
                      xmlns:rich="http://richfaces.org/rich"
                      template="layout/template.xhtml">
                             
      <ui:define name="body">
          
          <h:messages globalOnly="true" styleClass="message" id="globalMessages"/>
          
          <h:form id="firmSearch" styleClass="edit">
          
              <rich:simpleTogglePanel label="Firm search parameters" switchType="ajax">
              
                  <s:decorate template="layout/display.xhtml">
                      <ui:define name="label">firmCode</ui:define>
                      <h:inputText id="firmCode" value="#{firmList.firm.firmCode}"/>
                  </s:decorate>
      
                  <s:decorate template="layout/display.xhtml">
                      <ui:define name="label">firmDescription</ui:define>
                      <h:inputText id="firmDescription" value="#{firmList.firm.firmDescription}"/>
                  </s:decorate>
      
              
              </rich:simpleTogglePanel>
              
              <div class="actionButtons">
                  <h:commandButton id="search" value="Search" action="/FirmList.xhtml"/>
              </div>
              
          </h:form>
          
          <rich:panel>
              <f:facet name="header">Firm search results</f:facet>
          <div class="results" id="firmList">
      
          <h:outputText value="The firm search returned no results." 
                     rendered="#{empty firmList.resultList}"/>
                     
          <rich:dataTable id="firmList" 
                      var="firm"
                    value="#{firmList.resultList}" 
                 rendered="#{not empty firmList.resultList}">
              <h:column>
                  <f:facet name="header">
                      <s:link styleClass="columnHeader"
                                   value="firmCode #{firmList.order=='firmCode asc' ? messages.down : ( firmList.order=='firmCode desc' ? messages.up : '' )}">
                          <f:param name="order" value="#{firmList.order=='firmCode asc' ? 'firmCode desc' : 'firmCode asc'}"/>
                      </s:link>
                  </f:facet>
                  #{firm.firmCode}
              </h:column>
              <h:column>
                  <f:facet name="header">
                      <s:link styleClass="columnHeader"
                                   value="cfgCurrency currencyCode #{firmList.order=='cfgCurrency.currencyCode asc' ? messages.down : ( firmList.order=='cfgCurrency.currencyCode desc' ? messages.up : '' )}">
                          <f:param name="order" value="#{firmList.order=='cfgCurrency.currencyCode asc' ? 'cfgCurrency.currencyCode desc' : 'cfgCurrency.currencyCode asc'}"/>
                      </s:link>
                  </f:facet>
                  #{firm.cfgCurrency.currencyCode}
              </h:column>
              <h:column>
                  <f:facet name="header">
                      <s:link styleClass="columnHeader"
                                   value="firmDescription #{firmList.order=='firmDescription asc' ? messages.down : ( firmList.order=='firmDescription desc' ? messages.up : '' )}">
                          <f:param name="order" value="#{firmList.order=='firmDescription asc' ? 'firmDescription desc' : 'firmDescription asc'}"/>
                      </s:link>
                  </f:facet>
                  #{firm.firmDescription}
              </h:column>
              <h:column>
                  <f:facet name="header">action</f:facet>
                  <s:link view="/#{empty from ? 'Firm' : from}.xhtml" 
                         value="Select" 
                            id="firm">
                      <f:param name="firmFirmCode" 
                              value="#{firm.firmCode}"/>
                  </s:link>
              </h:column>
          </rich:dataTable>
      
          </div>
          </rich:panel>
          
          <div class="tableControl">
            
              <s:link view="/FirmList.xhtml" 
                  rendered="#{firmList.previousExists}" 
                     value="#{messages.left}#{messages.left} First Page"
                        id="firstPage">
                <f:param name="firstResult" value="0"/>
              </s:link>
              
              <s:link view="/FirmList.xhtml" 
                  rendered="#{firmList.previousExists}" 
                     value="#{messages.left} Previous Page"
                        id="previousPage">
                  <f:param name="firstResult" 
                          value="#{firmList.previousFirstResult}"/>
              </s:link>
              
              <s:link view="/FirmList.xhtml" 
                  rendered="#{firmList.nextExists}" 
                     value="Next Page #{messages.right}"
                        id="nextPage">
                  <f:param name="firstResult" 
                          value="#{firmList.nextFirstResult}"/>
              </s:link>
              
              <s:link view="/FirmList.xhtml" 
                  rendered="#{firmList.nextExists}" 
                     value="Last Page #{messages.right}#{messages.right}"
                        id="lastPage">
                  <f:param name="firstResult" 
                          value="#{firmList.lastFirstResult}"/>
              </s:link>
              
          </div>
          
          <s:div styleClass="actionButtons" rendered="#{empty from}">
              <s:button view="/FirmEdit.xhtml"
                          id="create" 
                       value="Create firm">
                  <f:param name="firmFirmCode"/>
              </s:button>
          </s:div>
          
      </ui:define>
      
      </ui:composition>
      
      



      Any idea will be welcomed! thanks in advance!