Bug in FilterRowDataProvider.{save,load}State()? [message #1017380] |
Mon, 11 March 2013 17:59 |
Patrick Rusk Messages: 35 Registered: June 2012 |
Member |
|
|
I believe FilterRowDataProvider.{save,load}State() have a bug in the way that they handle the persistence of filters. Here is the (highly edited) code:
public void saveState(String prefix, Properties properties) {
* * *
filterTextByIndex.put(columnIndex, (String) converter.canonicalToDisplayValue(filterObjectByIndex.get(columnIndex)));
* * *
}
public void loadState(String prefix, Properties properties) {
* * *
filterObjectByIndex.put(columnIndex, converter.displayToCanonicalValue(filterTextByIndex.get(columnIndex)));
* * *
}
The problem here is that the string used in the filter is converted to a display value on a save, then converted to canonical value on a load. That causes real problems with filters like ">500" on a numeric column. On the load, the conversion of ">500" to a number fails, and you get a message written to standard error saying "Error while restoring filter row text: ...".
Is there any good reason why the string isn't just saved and loaded "as is"?
This is a tough problem to fix without modifying the original source (like by creating a subclass of FilterRowDataProvider) because FilterRowDataProvider is referenced explicitly in FilterRowDataLayer, which is mentioned explicitly in FilterRowHeaderComposite.
[Updated on: Mon, 11 March 2013 18:02] Report message to a moderator
|
|
|
|
Re: Bug in FilterRowDataProvider.{save,load}State()? [message #1017947 is a reply to message #1017609] |
Tue, 12 March 2013 20:41 |
Patrick Rusk Messages: 35 Registered: June 2012 |
Member |
|
|
Quote:If you registered a converter to the filter row cell, e.g. an Integer converter, then how should a String for the matcher be restored to match an Integer?
Users type sequences of characters into filter cells, and the converter for that cell converts them into the Integer that it internally wants. Therefore, I would have expected that when the string is restored to the filter cell, the converter itself would convert it at that point.
Quote:You know that we are an open source project? If you find a bug and know how to fix it, try to contribute a bugfix via bugzilla and patch.
Heh. I have not always seen consistency in open source projects regarding bugs. Some want them discussed on forums until a committer says, "Add it as a bug", and some want them added as bugs right away. What is the convention for NatTable? I am glad to comply.
As for contributing a fix, I would have a steep learning curve to get to the point where I could do that (having not used Git, Maven, patch formats, etc.), but I'm willing to give it a shot. However, I would still need discussion on this topic (in Bugzilla, if more appropriate) before contributing a fix. What worked for me might not be generally applicable.
Thanks for looking into it.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03122 seconds