Can't Filter Integers

This forum is used by users to request and discuss new product features. Please do not use this forum for technical support including bug reports.

Moderator: JIDE Support

Forum rules
Product suggestions only. Please do not use this forum for technical support including bug reports.

Can't Filter Integers

Postby omeroksuzler » Thu Nov 30, 2017 6:05 am

Hello, I have a table that includes String, double, and int fields. For double areas, I can do numeric filters (for example: greater) no problem. But when I try to filter an int field it gives a ClassCastException saying java.lang.Integer cannot be cast to java.lang.String.
What am I doing wrong?
omeroksuzler
 
Posts: 16
Joined: Wed Nov 15, 2017 11:52 pm

Re: Can't Filter Integers

Postby JIDE Support » Thu Nov 30, 2017 10:53 am

It is most likely you didn't implement getColumnClass correctly in your table model. For the JIDE Grids, you should also implement ContextSenstitiveTableModel and implement its three methods accordingly especially getCellClassAt to return getColumnClass if all your table cells in the same column have the same data type.
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37145
Joined: Sun Sep 14, 2003 10:49 am

Re: Can't Filter Integers

Postby omeroksuzler » Thu Nov 30, 2017 11:00 am

Thanks for the reply!
That is the thing actually. I have the implementations you said. For the column, Integer.class is returned. And I'm also having problems with filtering date objects too. For example, BetweenFilter works fine for Date and InFilter doesn't work for the same Date objects.
omeroksuzler
 
Posts: 16
Joined: Wed Nov 15, 2017 11:52 pm

Re: Can't Filter Integers

Postby JIDE Support » Thu Nov 30, 2017 11:05 am

Please send me a simple test case so that I can run to see the issue. I know at least in the demo we provided, it worked as designed.
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37145
Joined: Sun Sep 14, 2003 10:49 am

Re: Can't Filter Integers

Postby omeroksuzler » Thu Nov 30, 2017 12:29 pm

I don't have the code with me now. But what I am trying to do is to use Jide's CustomTableFilterEditor to filter the data programmatically in my random table. Let's say the user wants to do a GreaterThanFilter with this column consisting of only integers. Right now, I'm only creating a GreaterThanFilter object and supplying the parameters to it and then supplying the Filter object to TableCustomFilterEditor instance. getColumnClassName is returning Integer.class for that column. If I do it this way, I get the exception. If the getColumnClassName returns Object.class or String.class for that column, then it is trying to do the filter text based. What else am I supposed to do? It should be enough for primitive types in my opinion. By the way, thanks again for bearing with me.

Important Edit: It is spesifically for this column, it works for other same type of columns, even without having to return Integer.class from getColumnClassName...

Edit 2: About dates, I send the parsed date objects (using SimpleDateFormat), to BetweenFilter and the filter works fine. But if I do the same thing for InFilter, the filter is applied but not finding any results.
omeroksuzler
 
Posts: 16
Joined: Wed Nov 15, 2017 11:52 pm

Re: Can't Filter Integers

Postby JIDE Support » Thu Nov 30, 2017 4:25 pm

That's I need a test case so that I can compile and debug to look into the issue.
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37145
Joined: Sun Sep 14, 2003 10:49 am

Re: Can't Filter Integers

Postby omeroksuzler » Mon Dec 04, 2017 12:42 am

Ok, inside getColumnClass I have something like:
if(name.equals("IntColumn")
return Integer. class;
etc.

and then insidr getCellClassAt
return getColumnClass(col) ;

and then when i do:
filterableTableModel.addFilter(8, new GreaterThanFilter(500)) ;
filterableTableModel.setFiltersApplied(true);

I get the exception.
omeroksuzler
 
Posts: 16
Joined: Wed Nov 15, 2017 11:52 pm

Re: Can't Filter Integers

Postby JIDE Support » Mon Dec 04, 2017 2:54 pm

Could you at least send the full stack trace? A test case will be really helpful. We can't possibly write a test case for every bug report we received. If you submit a bug for JDK, they won't even accept it without a test case. As a matter of fact, many users found what they did while writing a test case.
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37145
Joined: Sun Sep 14, 2003 10:49 am

Re: Can't Filter Integers

Postby omeroksuzler » Tue Dec 05, 2017 1:52 am

Ok, I solved that problem. I also had to implement getValueAt correctly. The problem I now have is with InFilter.

It works for all data types except Dates.
I create an object array and put date objects in it, then I send the array to InFilter's constructor. No exceptions, no errors, it applies the filter but can't find any matching rows. I create the date objects using SimpleDateFormat's parse method. Any ideas?
Edit: All other filters work with the same date objects. For example, I can do BetweenFilter which is actually more complex.
omeroksuzler
 
Posts: 16
Joined: Wed Nov 15, 2017 11:52 pm

Re: Can't Filter Integers

Postby JIDE Support » Tue Dec 05, 2017 10:23 am

Great. Again, a test case please. As you can see, if I didn't insist a test case, I would have spent hours to write a test case to replicate what you said, ending up with nothing.
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37145
Joined: Sun Sep 14, 2003 10:49 am


Return to Product Suggestions

Who is online

Users browsing this forum: No registered users and 2 guests