I have a jTable which is populated by data from a database using Beans Binding. I want to implement a search function for the table. I came across following tutorial which achieves this using beans binding:
https://weblogs.java.net/blog/pkeegan/archive/2008/06/using_beans_bin.html
I am unable to get it to work. When i run the sample application i created, i see an unexpected value such as "javax.swing.table.TableRowSorter@16994fe8" appearing on the search text field. This is actually coming from convertForward() method in the converter class which converts the TableRowSorter object to a string. Nothing happens when i type something on the text field.
I have set autoCreateRowSorter property of my jTable to true. I am not using a custom table model since the table is populated using beans binding using the default table model.
Noted that getTable(), setTable() or convertReverse() methods of the converter class are not getting invoked. I am wondering whether i missed anything in the process.
Given below is the code i am using to bind search text field with the jTable:
BindingGroup bindingGroup = new BindingGroup();
RowSorterToStringConverter bindingConverter = new RowSorterToStringConverter();
Binding searchBinding = Bindings.createAutoBinding(
UpdateStrategy.READ_WRITE,
employeeTable,
ELProperty.create("${rowSorter}"),
txtSearch,
BeanProperty.create("text"));
searchBinding.setConverter(bindingConverter);
bindingGroup.addBinding(searchBinding);
bindingGroup.bind();
Any help in this regard is greatly appreciated.