| Issue 136: | Custom FilterMatcher Tutorial | |
| 1 person starred this issue and may be notified of changes. | Back to list |
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
Status:
Fixed
|