0 Replies Latest reply on Nov 27, 2010 7:40 AM by Wilson Lima

    Table Filter + Select join

    Wilson Lima Newbie
      Hello, I have been studying Seam creating a application with seamgen and doing changes. SeamGen generates data tables with all the fields of that table in the database. So all the ids get listed which is not nice or human language. In this case the database table has relation with other, so I did a join to bring human-readable fields of all database tables involved in this case.



      `
      @Name("myClassList")
      public class MyClassList extends EntityQuery<AuxiliarListEntity> {

              private static final String EJBQL = "select new com.mypackage.AuxiliarListEntity(class_a, class_b, class_c) from ClassA class_a, ClassB class_b, ClassC class_c WHERE class_a.idClassC = class_c.idClassC and class_c.class_b.idClassB = class_b.idClassB";
             
              private static final String[] RESTRICTIONS = { "lower(class_c.name) like concat(lower(#{myClassList.class_c.name}),'%')", };
             
              private AuxiliarListEntity auxiliarListEntity= new AuxiliarListEntity(new ClassA(), new ClassB(), new ClassC());

              public MyClassList () {
                      setEjbql(EJBQL);
                      setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
                      setMaxResults(25);
                     
              }
             
              public AuxiliarListEntity getAuxiliarListEntity () {
                      return auxiliarListEntity ;
              }
             
      }

      `


      My AuxiliarListEntity class:



      `
      public class AuxiliarListEntity {
              private ClassA class_a;
              private ClassB class_b;
              private ClassC class_c;
             
             
              public AuxiliarListEntity (ClassA class_a, ClassB class_b,
                              ClassC class_c ) {
                      super();
                      this.class_a = class_a;
                      this.class_b = class_b;
                      this.class_c = class_c;
              }
             
      //Also here all the getters and setters


      }
      `

      My xhtml List File:

      `
      <ui:define name="body">

          <h:form id="myClassSearch" styleClass="edit">

              <rich:simpleTogglePanel label="MyClass Search Filter" switchType="ajax">
                              <s:decorate template="layout/display.xhtml">
                      <ui:define name="label">Name</ui:define>
                      <h:inputText id="name" value="#{myClassList.class_c.name}"/>
                  </s:decorate>

              </rich:simpleTogglePanel>

              <div class="actionButtons">
                  <h:commandButton id="search" value="Search" action="/MyClassList.xhtml"/>
                  <s:button id="reset" value="Reset" includePageParams="false"/>
              </div>

          </h:form>

          <rich:panel>
              <f:facet name="header">MyClass Search Results</f:facet>
          <div class="results" id="myClassList">

          <h:outputText value="The myclass search returned no results."
                     rendered="#{empty myClassList.resultList}"/>

          <rich:dataTable id="myClassList"
                      var="_myclass"
                    value="#{myClassList.resultList}"
                 rendered="#{not empty myClassList.resultList}">

              <h:column>
                  <f:facet name="header">
                      <ui:include src="layout/sort.xhtml">
                          <ui:param name="entityList" value="#{myClassList}"/>
                          <ui:param name="propertyLabel" value="Name Class C"/>
                          <ui:param name="propertyPath" value="class_c.name"/>
                      </ui:include>
                  </f:facet>
                  <h:outputText value="#{_myclass.class_c.name}"/>
              </h:column>
             
              <h:column>
                  <f:facet name="header">
                      <ui:include src="layout/sort.xhtml">
                          <ui:param name="entityList" value="#{myClassList}"/>
                          <ui:param name="propertyLabel" value="Name Class B"/>
                          <ui:param name="propertyPath" value="class_b.name"/>
                      </ui:include>
                  </f:facet>
                  <h:outputText value="#{_myclass.class_b.name}"/>
              </h:column>
             
              <h:column>
                  <f:facet name="header">
                      <ui:include src="layout/sort.xhtml">
                          <ui:param name="entityList" value="#{myClassList}"/>
                          <ui:param name="propertyLabel" value="Name Class A"/>
                          <ui:param name="propertyPath" value="class_a.name"/>
                      </ui:include>
                  </f:facet>
                  <h:outputText value="#{_myclass.class_a.name}"/>
              </h:column>
              
          </rich:dataTable>

          </div>
          </rich:panel>
      </ui:define>
      `

      What happens is that nothing gets filtered according to what I type (I type existing values in one row!!).

      What I noticed is that other entities in the seamgen... That the filtering does work, the typed value appears in the browser url field like:

      ´name=typed_value´

      Im very new to Seam, although I had developed with hibernate, spring and myFaces several years ago I´m have some pain to get the heck of some of the features. If someone much more experience could help I would be very grateful.