Friday, November 26, 2010

Clearing Filter criteria in ADF Rich Table

Hi Friends,this is one of my use-case for removing the filter text in the table when clicking a command button.
I think you all like this scenario.

Logic is,
           ADF table filter uses SearchRegion binding, which genearly uses a All Queriable Attributes Criteria. It will apply the criteria on the View object. So we need to clear the criteria on the view object.

The Solution is,
        1.Bind a table in the Jspx to a managed bean,say summaryTable.
        2.In the Jspx page,use a commandButton and in its Action property call a method in the managed bean for eg: clearFilters()

        3.Type the following code in the method,
  public String clearFilters(){
      if (summaryTable != null){
      FilterableQueryDescriptor queryDescriptor =
                                        (FilterableQueryDescriptor)summaryTable.getFilterModel();
      if (queryDescriptor != null && queryDescriptor.getFilterCriteria() != null){
      queryDescriptor.getFilterCriteria().clear();
      summaryTable.queueEvent(new QueryEvent(summaryTable,queryDescriptor));
      }
      else{
          String message = "Have some problem in Clearing Filters. please try later";
          FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(message));
      }
      }
      return null;
  }


Now you run your application,type some filter text and click in the Button which will clear the filter text.
This example I tried in JDeveloper 11.1.1.2.0 . I hope it will work in all the versions of JDeveloper.If any problem post your comments or mail to felixandrew3@gmail.com

No comments:

Post a Comment