I have a web service that populates a table, using a SelectableListTableContentProvider, which works nicely.
However if I add a Filter Input control to the table, all it does is filter on the current table contents on the client side, ie if I'm on page 1 of 10 of the table, it doesn't go and check all values, just the ones on page 1.
How do I make a Filter Input control filter on all the values that the web service can return?
Here's how you do it:
Create as you say a
SelectableListTableContentProvider
(let's call itmyDataProvider
), and make sure all that stuff works between the web service, the provider and the screen. This is just in case there's a mistake here and the next bit then won't work properly. Just make sure it looks normal, pages through the data properly, etc. Give the table a nice, descriptive ID.Add a Filter Input control to the screen. Set its
For
property to be the ID of the table.Go into your code and change
myDataProvider
's type fromSelectableListTableContentProvider
toFilterableSelectableListTableContentProvider
. You will need to do it in the variable's declaration:In two places in its getter:
AND in the managed bean config in
faces-config.xml
:In each example I'm showing what it looks like before it's changed. Just add the word
Filter
beforeSelectableListTableContentProvider
.Now you have a filterable content provider.
The screen will error at this point if you try to run it. Why? Good question. Why, Software AG? Why don't you provide a sensible default? Why do we have to pick which field to filter on, unlike the out of the box behaviour of the client-side Filter Input control, which just defaults to filtering on everything?
Anyway. Open up the filterable provider in the Bindings pane. It looks a bit weird, because I don't think they've configured this as well as they could. Pick the
Row Filter Value Binding
property (its icon is a * in a box; don't know why it's not a string) and set its Data Binding property to be the Controls Scoped Variable of the correct field in the provider.That doesn't make sense? Okay, I'll break it down:
Row Filter Value Binding
under your provider in the Bindings pane.#{...}
button to browse for the value you want.Controls Scoped Variables
section. If this doesn't exist, go back to a) and do it properly :)Hit okay. The field will be bound to something that looks like this:
Deploy and enjoy :)