2 Replies Latest reply on Jun 17, 2008 2:57 PM by antonio attadia

    data columns filtering

    antonio attadia Newbie

      Hello everibody,
      I'm using jboss-seam 2.0.2.CR2 .
      I want to filter data rows with this facelet(obtained from a  cut and past from a richfaces example):


      <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 id="table" 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 filterMethod="#{filteringBean.filterStates}" filterEvent="onkeyup">
                      <f:facet name="header">
                          <h:inputText value="#{filteringBean.filterValue}" id="input">
                          <a4j:support reRender="table"
                                  ignoreDupResponses="true" requestDelay="700" focus="input" />
                          </h:inputText>
                      </f:facet>
                      <h:outputText value="#{cap.state}"/>
                  </rich:column> 
                      <rich:column >
                      <h:outputText value="#{cap.name}"/> 
                  </rich:column>
              </rich:dataTable>
          </h:form>
      </ui:composition>
      


      This is my bean:


      package filtering;
      
      import javax.swing.DefaultRowSorter;
      import javax.swing.RowFilter;
      
      import org.jboss.seam.annotations.Name;
      
      import it.wizardsgroup.qtram.session.Capitals;
      
      @Name("filteringBean")
      public class FilteringBean {
      
              private String filterValue="";
              
              public String getFilterValue() {
                      return filterValue;
              }
      
              public void setFilterValue(String filterValue) {
                      this.filterValue = filterValue;
              }
      
              public boolean filterStates(Object current) {
      
              Capitals currentCapital = (Capitals)current;
              if (filterValue.length()==0) {
                  return true;
              }
              if (currentCapital.getState().toLowerCase().startsWith(filterValue.toLowerCase())) {
                  return true;
              }else {
                  return false; 
              }
          }
      }
      



      The rows of my table are shown but filtering dont work.
      Someone could explain me wy and some solution?


      Tanks a lot for every suggestion!