0 Replies Latest reply on May 23, 2007 10:08 AM by thephil

    UI: Filtering with drop-downs does not work

    thephil

      I am running JBoss 4.0.5 with ejb3 profile. I am using Seam 1.2.1.GA.

      I have generated a CRUD Seam application with "seam generate-entities". Now I would like to filter results for the list pages using a drop down.

      1. The list page displays parameters. Each parameter is linked to a category (own entity/db table).
      2. I now wanted to add a dropdown to select filter parameters based on category.

      However, it does not seem to work. Could somebody please help me out on this one? Maybe I am just thinking too complicated...

      Here is what I did:

      ParameterList.java (extends EntityQuery)
      I added one Line to the RESTRICTIONS array. It now looks like this:

      @Name("parameterList")
      public class ParameterList extends EntityQuery {
      
      private static final String[] RESTRICTIONS = {
       "lower(parameter.name) like concat(lower(#{parameterList.parameter.name}),'%')",
       "lower(parameter.description) like concat(lower(#{parameterList.parameter.description}),'%')",
       "lower(parameter.designDocument) like concat(lower(#{parameterList.parameter.designDocument}),'%')",
       "lower(parameter.settingsDescription) like concat(lower(#{parameterList.parameter.settingsDescription}),'%')",
       "parameter.paramcategory.paramcategoryId = #{parameterList.parameter.paramcategory.paramcategoryId}",};
      


      (I have added only the last line. Paramcategory is the category of the parameter.)

      ParameterList.xhtml
      I added the dropdown menu. I looked at the seam ui example and tried to map that code to my application.

      <rich:simpleTogglePanel label="Parameter search parameters" switchType="ajax">
      
      [... other search fields ...]
      
       <s:decorate template="layout/display.xhtml">
       <ui:define name="label">settingsDescription</ui:define>
       <h:inputText id="settingsDescription" value="#{parameterList.parameter.settingsDescription}"/>
       </s:decorate>
      
      [... here comes my searchfield ...]
      
       <s:decorate template="layout/display.xhtml">
       <ui:define name="label">category</ui:define>
       <h:selectOneMenu value="#{parameterList.parameter.paramcategory}" >
       <s:selectItems value="#{paramcategoryList.resultList}" var="category" label="#{category.name}" />
       <s:convertEntity />
       </h:selectOneMenu>
       </s:decorate>
      </rich:simpleTogglePanel>
      


      If I select something from the dropdown, no filtering happens. In the logfile, you can see that Hibernate assembles the SELECT statement to the DB correctly:
      2007-05-22 13:35:31,915 DEBUG [org.hibernate.SQL] select * from ( select parameter0_.PARAMETER_ID as PARAMETER1_69_, parameter0_.CATEGORY_ID as CATEGORY8_69_, parameter0_.TYPE_ID as TYPE6_69_, parameter0_.STATUS_ID as STATUS7_69_, parameter0_.DESIGN_DOCUMENT as DESIGN2_69_, parameter0_.SETTINGS_DESCRIPTION as SETTINGS3_69_, parameter0_.NAME as NAME69_, parameter0_.DESCRIPTION as DESCRIPT5_69_ from MICSCONF.PARAMETER parameter0_ where parameter0_.CATEGORY_ID=? ) where rownum <= ?
      
      2007-05-22 13:35:31,915 INFO [STDOUT] Hibernate: select * from ( select parameter0_.PARAMETER_ID as PARAMETER1_69_, parameter0_.CATEGORY_ID as CATEGORY8_69_, parameter0_.TYPE_ID as TYPE6_69_, parameter0_.STATUS_ID as STATUS7_69_, parameter0_.DESIGN_DOCUMENT as DESIGN2_69_, parameter0_.SETTINGS_DESCRIPTION as SETTINGS3_69_, parameter0_.NAME as NAME69_, parameter0_.DESCRIPTION as DESCRIPT5_69_ from MICSCONF.PARAMETER parameter0_ where parameter0_.CATEGORY_ID=? ) where rownum <= ?
      
      2007-05-22 13:35:31,915 DEBUG [org.hibernate.loader.hql.QueryLoader] bindNamedParameters() 3 -> el5 [1]
      

      However, no filtering happens in the result on the webpage. Also, the selection of the dropdown is not being preserved (after page reload, the dropdown shows the default category, not the one I selected earlier).

      Can anybody help me please? I am running down against wall now...