| Issue 162: | FilterMatcherRegistry fails when the filter set contains a property that is not available | |
| 2 people starred this issue and may be notified of changes. | Back to list |
From my query I am returning a list of Maps to represent the rows. I have a filter value defined for a property that is not part of the result set (i'm using that filter value in my query, using a custom filter renderer). We the default filtering strategy kicks in, I get the following stack trace: [11/7/08 11:23:52:968 EST] 00000021 SimpleRowFilt E [re.filter.SimpleRowFilter] [getFilterMatche] Had problems getting the Filter / FilterMatcher values. java.lang.NullPointerException at java.lang.Class.isAssignableFrom(Native Method) at org.jmesa.core.filter.FilterMatcherRegistryImpl.getFilterMatcherByObject(FilterMatcherRegistryImpl.java:120) at org.jmesa.core.filter.FilterMatcherRegistryImpl.getFilterMatcher(FilterMatcherRegistryImpl.java:45) at org.jmesa.core.filter.SimpleRowFilter.getFilterMatchers(SimpleRowFilter.java:72) at org.jmesa.core.filter.SimpleRowFilter.filterItems(SimpleRowFilter.java:50) at org.jmesa.core.ItemsImpl.<init>(ItemsImpl.java:45) at org.jmesa.core.CoreContextFactoryImpl.createCoreContext(CoreContextFactoryImpl.java:141) at org.jmesa.facade.TableFacadeImpl.getCoreContext(TableFacadeImpl.java:365) Presumably, the problem is here: Class<?> type = getPropertyClassType(items, property); MatcherKey key = new MatcherKey(type, property); FilterMatcher filterMatcher = registry.getFilterMatcher(key); I think that getPropertyClassType is returning a null value for the property.
Nov 7, 2008
#1
bgo...@e1b.org
Nov 7, 2008
I completely agree. My thought process at the time was that this would be caught during development. But your right that with custom implementations the assumption may not always hold up. Probably should just log it out and move on. Would you think a log type of warn is too high? Or should it just be a debug? -jeff
Status:
Accepted
Nov 7, 2008
I wonder if there is a way to throw an exception by default (as it does not), but also allow a user to set a flag to emit a debug message and just drive on?
Apr 20, 2009
Hey guys , I am having exactly the same issue, Have a property that is not part of the result set and getting the exception stated above. You guys mention "The workaround is to not use default filtering". How do you do that ? I tried tableFacade.addFilterMatcher(new MatcherKey(Object.class, "prop_name"), new FilterMatcher()); But that did not resolve it. Any thoughts ?
Apr 20, 2009
You can swap in your own filtering in place of SimpleRowFilter. The SimpleRowFilter implements the RowFilter interface and that can be plugged in for something custom. If you wanted to use the registry mechanism you would have to make sure you bring that in and instantiate it on your constructor as well. I think we would be better off addressing the issue though. The question is what to do. I have the exception in there to help the developer out so I'm not sure it makes sense to just swallow the error. Let me think about it a bit more and we'll figure something out. I will also find some time to write up a wiki page that explains how to swap in your own filter strategy for more options.
Apr 21, 2009
I updated the SimpleRowFilter to be easier to extend. What I would recommend you doing is just copy the SimpleRowFilter and override the getFilterMatchers() method. There is not too much too it and then you can handle the error how you feel is best. I will deal with it at some point but I'm still not sure what that will be. I wrote up a quick example that shows how to overwrite the method that you need. https://code.google.com/p/jmesa/wiki/CustomSimpleRowFilter The code is available on the trunk. Or you can email me at jeff.johnston.mn@gmail.com and I can send out a build for you.
Status:
Started
Mar 9, 2011
Fixed by making the SimpleRowFilter easier to extend.
Status:
Fixed
|