• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I am trying to get a tableview filter to work

 
Roger Wells
Ranch Hand
Posts: 51
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to filter my tableview using a txfFilter. The txfFilter seems to work but I
don't know how to connect that to the filterList and then have that list loaded into my
tableview.

This is around line 195 to 205

Any help would be appreciated

Thanks Roger



 
Roger Wells
Ranch Hand
Posts: 51
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK I seem to be down to this one problem. Line 21 s.contains is invalid. I think it is a type problem
but am not sure.

Again hope someone can help
Thanks
Roger


 
Tobias Bachert
Ranch Hand
Posts: 46
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
setPredicate seems to accept a -> the argument is of type Citation and your Citation class does not contain a 'contains(String)' method.
 
Roger Wells
Ranch Hand
Posts: 51
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That sounds reasonable but how do I fix it?

I am lost

Roger
 
Knute Snortum
Bartender
Pie
Posts: 2912
62
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the filter for the field name or code or both?  You want make a statement out of s that will evaluate to a boolean.
 
Roger Wells
Ranch Hand
Posts: 51
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am at this point flustered..

filteredData.setPredicate(s -> s.contains(filter))

I think this statement should filter the filteredData so that nothing but the items that
contain the data found within filteredData and then that will be added to the tableView.

s.contains is not a good option for this and as a result it will not filter the filteredData

Hope someone can help as I still am lost

Roger
 
Knute Snortum
Bartender
Pie
Posts: 2912
62
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In this line:

what type is s?  It's a type Citation which you have defined.  So you can only call the methods on s that are in the class Citation.

Since the method wants a predicate, that means it return true or false (boolean).  So how do we get a boolean value from s?

One thing we can do is search for the filter in the fields of Citation.  You haven't stated if the filter should be for name or code, so I'll assume it's both.

What can you do to see it a string contains another string?  Use the contains() method, of course!  So a simple implementation might be:
 
Roger Wells
Ranch Hand
Posts: 51
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you it worked and I now understand what it is doing.

I did make some changes but your suggestion made it work

 
Knute Snortum
Bartender
Pie
Posts: 2912
62
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Glad I could help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic