Issue 136: Custom FilterMatcher Tutorial
Status:  Fixed
Owner:
Closed:  Aug 2008
Project Member Reported by jeff.johnston.mn@gmail.com, Aug 21, 2008
This was on the groups under the name ryan.tromp@gmail.com


The first thing you do is create a custom DroplistFilterEditor like
the following :

public class AvailableDroplistFilterEditor extends
DroplistFilterEditor {

       public List<Option> getOptions()  {
               List<Option> options = new ArrayList<Option>();
               options.add(new Option("Available","Available"));
               options.add(new Option("Available", "Available"));
               return options;
       }
}


Then you implement a custom FilterMatcher (this could possibly be
cleaned up with a case statement):

public class AvailableFilterMatcher implements FilterMatcher
{

       public boolean evaluate(Object itemValue, String filterValue){

               if (StringUtils.equalsIgnoreCase(filterValue, new
String("available"))){

                       if (StringUtils.lowerCase(String.valueOf(itemValue))
== "true"){
                               return true;
                       }
               }

               else if (StringUtils.equalsIgnoreCase(filterValue, new
String("unavailable"))){

                       if (StringUtils.lowerCase(String.valueOf(itemValue))
== "false"){
                                       return true;
                       }
               }

               return false;

       }
}



Finally, add the filter matcher to the table facade before you start
setting up your columns :

tableFacade.addFilterMatcher(new MatcherKey(String.class,
"available"), new AvailableFilterMatcher());
Aug 23, 2008
Project Member #1 jeff.johnston.mn@gmail.com
Added this to the wiki.
Status: Fixed