4 Replies Latest reply on May 25, 2013 6:40 AM by Pawel Kleczek

    How to use rich:componentControl to filter a table?

    Pawel Kleczek Newbie

      I try to reuse this sample: http://showcase.richfaces.org/richfaces/component-sample.jsf?demo=componentControl in my application.


      Here's what I have:


      XHTML file

      <rich:extendedDataTable value="#{overviewHandler.tournaments}"
          var="tour" id="table">
              <h:outputLink value="#">
                  <rich:componentControl target="allMatches" operation="filter"
                          <f:param value="tournamentId" />
                          <f:param value="#{tour.id}" />
                  <h:outputText value="#{tour.name}" />

      <rich:dataTable value="#{overviewHandler.tournaments}" rows="100"
          <rich:column id="tournamentId"
              <rich:collapsibleSubTableToggler for="matchSubtable" />
              <h:outputText value="#{tournament.name}" />
          <rich:collapsibleSubTable value="#{tournament.matches}"
              var="match" id="matchSubtable">



      package jsf;
      import java.io.Serializable;
      import javax.faces.bean.ManagedBean;
      import javax.faces.bean.SessionScoped;
      import model.Tournament;
      import org.richfaces.model.Filter;
      public class TournamentFilteringBean implements Serializable
            private String                                        idFilter                              = "";
                public Filter<?> getFilterId()
                          return new Filter<Tournament>()
                                    public boolean accept(Tournament t)
                                              return (getIdFilter().isEmpty() || getIdFilter().equals(t.getId().toString()));
                public String getIdFilter()
                          return idFilter;
                public void setIdFilter(String idFilter)
                          this.idFilter = idFilter;


      But when I click on a link (h:outputLink) nothing in the main table is filtered. I'm not sure what is the meaning of these two parameters used in the tutorial in the <rich:componentControl> tag.


      OK, what I want to achieve is - when a user clicks on the name of a tournament, the table with all tournaments and their matches should be filtered so that only entries for the selected tournament are visible.

      So basically the question is: how can I set the "idFilter" field in my filtering bean and then invoke the filtering operation on the table when a user clicks on a link?