3 Replies Latest reply on Jun 5, 2008 6:26 AM by zed1284

    search function using filterBy

    zed1284

      I´m trying to implement a search function using the filterBy attribute like in this example: http://livedemo.exadel.com/richfaces-demo/richfaces/filteringFeature.jsf?c=filtering

      But it doesn´t work! Can somebody tell me if this example isn`t right? I wonder why there is no inputtext in the code where i can type in although the page contains the input-fields. I changed the outputtext into inputtext but nothing happens when i type something in!

      I haven´t found another example which uses the filterBy functionality. Does anyone know a good page with some examples or tutorials for implementing a search or filtering method?

      This is the source code from this page above

      <ui:composition xmlns="http://www.w3.org/1999/xhtml"

      xmlns:ui="http://java.sun.com/jsf/facelets"

      xmlns:h="http://java.sun.com/jsf/html"

      xmlns:f="http://java.sun.com/jsf/core"

      xmlns:a4j="http://richfaces.org/a4j"

      xmlns:rich="http://richfaces.org/rich">

      <h:form>

      <rich:dataTable value="#{capitalsBean.capitals}" var="cap">

      <f:facet name="header">

      <rich:columnGroup>

      <rich:column colspan="2" >

      <h:outputText value="Filtering Example"/>

      </rich:column>

      <rich:column breakBefore="true">

      <h:outputText value="State Name"/>

      </rich:column>

      <rich:column>

      <h:outputText value="State Capital"/>

      </rich:column>

      </rich:columnGroup>

      </f:facet>

      <rich:column filterBy="#{cap.state}" filterEvent="onkeyup">

      <f:facet name="header">

      <h:outputText value=" " title="Hack due to bug. Shuold be remoevd till release"></h:outputText>

      </f:facet>

      <h:outputText value="#{cap.state}"/>

      </rich:column>

      <rich:column filterBy="#{cap.name}" filterEvent="onkeyup">

      <h:outputText value="#{cap.name}"/>

      </rich:column>

      </rich:dataTable>

      </h:form>

      </ui:composition>

        • 1. Re: search function using filterBy
          ilya_shaikovsky

          in this demo code - built in filtering used. So there is inplaces in headers generated automatically.

          If you need to implement external filtering. (with external filtering field and serch button ) - explore second tab of filtering demo page.

          • 2. Re: search function using filterBy
            zed1284

            Thx! But I still have a problem with external filtering. When I type in the first time, it disappears after 500 ms and then I can type in whatever I want and nothing happens.

            This is my View:

            <!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"
             xmlns:a4j="http://richfaces.org/a4j"
             template="layout/template.xhtml">
            
            <ui:define name="body">
            
             <s:link value="Home" view="/home.xhtml" /> ->
             <s:link value="Produktgruppenverwaltung" disabled="true" />
            
             <h:messages globalOnly="true" styleClass="message"/>
            
             <rich:panel rendered="#{identity.loggedIn}">
             <h:form>
             <rich:spacer height="15" />
             <s:button value="Neue Produktgruppe hinzufuegen" view="/produktGruppenAdd.xhtml" />
             <rich:dataTable id="prodgruppeID" rows="10" columnClasses="col"
             value="#{prodgruppeAction.getListe()}" var="prod">
             <f:facet name="header">
             <rich:columnGroup>
             <rich:column>
             <h:outputText styleClass="headerText" value="Bezeichnung" />
             </rich:column>
             <rich:column>
             <h:outputText styleClass="headerText" value="Bearbeiten" />
             </rich:column>
             <rich:column>
             <h:outputText styleClass="headerText" value="L&#246;schen" />
             </rich:column>
             </rich:columnGroup>
             </f:facet>
             <rich:column filterMethod="#{prodgruppeAction.filterPG}">
             <f:facet name="header">
             <h:inputText value="#{prodgruppeAction.filterValue}" id="input">
             <a4j:support event="onkeyup" reRender="prodgruppeID"
             ignoreDupResponses="true" requestDelay="500" focus="input" />
             </h:inputText>
             </f:facet>
             <h:outputText value="#{prod.bezeichnung}"/>
             </rich:column>
             <rich:column>
             <f:facet name="header">
             <h:outputText title="Hack due to bug">...</h:outputText>
             </f:facet>
             <h:commandLink action="#{prodgruppeAction.showDetailsEdit(prod)}" value="Bearbeiten"/>
             </rich:column>
             <rich:column>
             <f:facet name="header">
             <h:outputText title="Hack due to bug">...</h:outputText>
             </f:facet>
             <h:commandButton value="L&#246;schen" action="#{prodgruppeAction.delete(prod)}"/>
             </rich:column>
             </rich:dataTable>
            
             <rich:datascroller align="left" for="prodgruppeID" maxPages="20"
             id="sc2" />
             </h:form>
             </rich:panel>
            </ui:define>
            </ui:composition>


            And this is my FilterMethod as discribed here http://livedemo.exadel.com/richfaces-demo/richfaces/filteringFeature.jsf;jsessionid=FB3596EDBFA5083818701D1BC1B103B1:

             public boolean filterPG(Object current) {
            
             Produktgruppe currentPG = (Produktgruppe)current;
             System.out.println(currentPG.getBezeichnung());
             if (filterValue.length()==0) {
             return true;
             }
             if (currentPG.getBezeichnung().toLowerCase().startsWith(filterValue.toLowerCase())) {
             return true;
             }else {
             return false;
            
             }
            
             }



            • 3. Re: search function using filterBy
              zed1284

              Has nobody any ideas? Does anybody know an example with filtering? This is very important for me!!