2 Replies Latest reply on Jun 17, 2013 9:14 AM by dageisz

    4.3.1: ExtendedDataTable: filterType custom and clearing of filter input doesnt work correctly

    dako ak Newbie

      I have a simple extendedDataTable with one column (firstName) with a filter input component within the header. This is the default filter input created by the extendedDataTable. The second column (city) has a filterType="custom" and an inputText componenent within the header. The filterType attribute with value "custom" is ignored because the default input text is rendered too.

      The second problem with the input filter is that I can't clear this filter input text components by a a4j:commandButton. The table is correct filtered but the filter input text fields are not cleared.

       

      I have created a JIRA issue, but maybe someone has a workaround?

      https://issues.jboss.org/browse/RF-12943

      Within this JIRA issue you can download a simple test project to reproduce the problems.

       

      And now the code:

       

      XHTML page

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
              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:a4j="http://richfaces.org/a4j"
              xmlns:rich="http://richfaces.org/rich"
              xmlns:fn="http://java.sun.com/jsp/jstl/functions">
      
      <h:head>
          <title>RichFaces-Test: start page</title>
      </h:head>
      <h:body>
          <h3>RichFaces-Test: start page</h3>
          <h:form id="overviewForm">
              <p>
                  <h:outputText value="List of persons:" /> 
              </p>
              
              <p>
                  <a4j:commandButton value="Clear filter and refresh" action="#{overviewController.clearFilter()}" render="overviewTable" execute="@form"/>
              </p>
              
              
              <rich:extendedDataTable id="overviewTable" rowKeyVar="index"
                  columnsOrder="#{overviewController.columnsOrder}"
                  value="#{overviewController.tableItems}" var="tableItem"
                  rows="15">
      
                  <f:facet name="header">
                  </f:facet>
                  
                  <rich:column id="city" filterValue="#{overviewController.cityFilter}" filterType="custom"
                      filterExpression="#{fn:containsIgnoreCase(tableItem.city, fn:trim(overviewController.cityFilter))}">
                      <f:facet name="header">
                          <h:outputText value="City" />    
                          
                          <h:inputText id="cityFilter" style="width:99.9%" value="#{overviewController.cityFilter}">
                              <a4j:ajax event="change" render="overviewTable" execute="@this" />
                          </h:inputText>
                      </f:facet>
                      <h:outputText value="#{tableItem.city}" />                
                  </rich:column>
                  
                  <rich:column id="firstName" filterValue="#{overviewController.firstNameFilter}"
                      filterExpression="#{fn:containsIgnoreCase(tableItem.firstName, fn:trim(overviewController.firstNameFilter))}">
                      <f:facet name="header">
                          <h:outputText value="First Name" />    
                      </f:facet>
                      <h:outputText value="#{tableItem.firstName}" />                
                  </rich:column>
                  
                  <rich:column id="country">
                      <f:facet name="header">
                          <h:outputText value="Country" />    
                      </f:facet>
                      <h:outputText value="#{tableItem.country}" />                
                  </rich:column>
                  
              </rich:extendedDataTable>    
              
          </h:form>
      </h:body>
      </html>
      

       

       

      The code of the overviewController:

       

       

      @ManagedBean

      @SessionScoped

      public class OverviewController implements Serializable{

         

          private static final long serialVersionUID = 544466031058458542L;

       

          private List<TableItem> tableItems;

          private String[] columnsOrder;

          private String cityFilter;

          private String firstNameFilter;

         

          @PostConstruct

          public void postConstruct() {

              System.out.println("start: postConstruct");

       

              tableItems = new ArrayList<TableItem>();

              tableItems.add(new TableItem("Oliver", "New York", "USA"));

              tableItems.add(new TableItem("Jane", "Washington", "USA"));

              tableItems.add(new TableItem("Fred", "Berlin", "Germany"));

              tableItems.add(new TableItem("Thomas", "London", "England"));

             

              columnsOrder = new String[] {"firstName", "city", "country" };

          }

         

          public void clearFilter() {

              System.out.println("clearFilter");

              cityFilter = "";

              firstNameFilter = "";

          }

       

         

         

       

          public List<TableItem> getTableItems() {

              return tableItems;

          }

         

          public void setTableItems(List<TableItem> tableItems) {

              this.tableItems = tableItems;

          }

       

          public String[] getColumnsOrder() {

              return columnsOrder;

          }

       

          public String getCityFilter() {

              return cityFilter;

          }

         

          public void setCityFilter(String cityFilter) {

              this.cityFilter = cityFilter;

          }

       

          public String getFirstNameFilter() {

              return firstNameFilter;

          }

         

          public void setFirstNameFilter(String firstNameFilter) {

              this.firstNameFilter = firstNameFilter;

          }

       

      }

       

      Best regards