0 Replies Latest reply on Mar 18, 2009 5:34 PM by bobgee

    advance page search result

      Hi!


      I have altered a seam generated list page by replacing in the search panel an input field by an option list. It's a printer list where printers are linked @OneToMany to manufacturers.
      My question is how to pass the manufacturer (id) to the next page in the result list page.


      PrinterList.xhtml:


              <rich:simpleTogglePanel label="#{messages.searchFilter}" switchType="ajax">
      
                  <s:decorate template="layout/display.xhtml">
                      <ui:define name="label">Manufacturer</ui:define>
                       <h:selectOneMenu id="manufacturerid" value="#{examplePrinter.manufacturer}" required="false" onchange="submit()">
                               <s:selectItems value="#{manufacturers.resultList}" 
                                 var="_manufacturer" label="#{_manufacturer.name}"
                                 noSelectionLabel="#{messages.UnassignedOption}" hideNoSelectionLabel="false"/>
                               <s:convertEntity />
                         </h:selectOneMenu>
                  </s:decorate>
      
                  <s:decorate template="layout/display.xhtml">
                      <ui:define name="label">Modelname</ui:define>
                      <h:inputText id="modelname" value="#{examplePrinter.modelname}"/>
                  </s:decorate>
      
              </rich:simpleTogglePanel>
      
              <div class="actionButtons">
                  <input type="hidden" name="firstResult" value="0"/>
                  <h:commandButton id="search" value="#{messages.searchSearch}" action="/PrinterList.xhtml"/>
                  <s:button id="reset" value="#{messages.searchReset}" includePageParams="false"/>
              </div>
      
      ...
      
                   <s:link view="/PrinterList.xhtml"
                       rendered="#{printerList.nextExists}"
                             id="nextPage">
                       <h:graphicImage value="#{messages.imgPageNext}"/>
                       <f:param name="firstResult"
                               value="#{listBean.nextFirstResult}"/>
                   </s:link>
      
      



      PrinterList.page.xml:


         <param name="firstResult" value="#{printerList.firstResult}"/>
         <param name="sort" value="#{printerList.orderColumn}"/>
         <param name="dir" value="#{printerList.orderDirection}"/>
      
         <param name="from"/>
         <param name="manufacturername" value="#{exampleManufacturer.name}"/>
         <param name="modelname" value="#{examplePrinter.modelname}"/>
      



      Missing here something like:


      <param name="manufacturerid" value="#{examplePrinter.manufacturer}"/>
      



      Here's the question!
      The search works fine when I chose one manufacturer from the option list (onchange submit!).
      The first result page is correct. The manufacturer in the option list is selected. But when I press the next button, the result list comes (surely) without considering the chosen manufacturer.
      The question is how to specify the manufacturerid as a page paramater in .page.xml.
      In PrinterList.xhtml manufacturerid is set to the manufacturer's id because of s:convertEntity, but how can I accomplish this in .page.xml???
      There, examplePrinter.manufacturer results to the class id


      (&manufacturerid=....Manufacturer@d38dc4&cid=89)



      If I specify


      <param name="manufacturerid" value="#{examplePrinter.manufacturer.id}"/>



      I get the error Target Unreachable, 'manufacturer' returned null on 'x.x.x.entity.Printer'


      But anyway it's not the right approach to get in the manufacturer's id.



      components.xml:


      <component name="examplePrinter"
          class="xxx.xxx.xxx.entity.Printer"/>
      
      <component name="exampleManufacturer"
          class="xxx.xxx.xxx.entity.Manufacturer"/>
      
      <framework:entity-query class="xxx.xxx.xxx.session.EntityQueryExtended"
           name="printerList"
           max-results="#{messages.resultsPerPage}"
           ejbql="select printer from Printer printer join printer.manufacturer manufacturer"
           order="printer.manufacturer.name, printer.generic desc, printer.modelname"
           >
           <framework:restrictions>
               <value>lower(printer.manufacturer.name) like concat('%', lower(#{exampleManufacturer.name}),'%')</value>
                <value>lower(printer.modelname) like concat('%', lower(#{examplePrinter.modelname}),'%')</value>
               <value>manufacturer = #{examplePrinter.manufacturer}</value>
           </framework:restrictions>
      </framework:entity-query>
      



      More code needed?
      Thank for your time!


      Regards, Robert