Hello all,

I ll go straight to my problem:

I have a jTable with Payments (int id, String name, Date date, double amount) and I would like to filter the data so it will display only the records between two specified dates taken from two jDateChooser controls of the jCalendar. To do that I create a sorter as I did to add search functionality on the jtable binded with a textField (the search works fine). The code for the filter is the following:

Java Code:
import com.toedter.calendar.JDateChooser;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JTable;
import javax.swing.RowFilter;
import javax.swing.table.TableRowSorter;
import org.jdesktop.beansbinding.Converter;

public class DateRowSorterConverter extends Converter {

    private JTable table;
    private JDateChooser from;
    private JDateChooser to;

    public JDateChooser getFrom() {
        return from;
    }

    public void setFrom(JDateChooser from) {
        this.from = from;
    }

    public JDateChooser getTo() {
        return to;
    }

    public void setTo(JDateChooser to) {
        this.to = to;
    }

    public JTable getTable() {
        return table;
    }

    public void setTable(JTable table) {
        this.table = table;
    }

    @Override
    public Object convertForward(Object value) {
        return value.toString();
    }

    @Override
    public Object convertReverse(Object mask) {
        TableRowSorter sorter = new TableRowSorter(table.getModel());

        List filters = new ArrayList<RowFilter<Object,Object>>();

        if (from != null){
            RowFilter filter1 = RowFilter.dateFilter(RowFilter.ComparisonType.AFTER, from.getDate());
            filters.add(filter1);
        }
        if (to != null){
            RowFilter filter2 = RowFilter.dateFilter(RowFilter.ComparisonType.BEFORE, to.getDate());
            filters.add(filter2);
        }

        RowFilter filter = RowFilter.andFilter(filters);

        sorter.setRowFilter(filter);
        
        return sorter;
    }
}
To bind the sorter and the jDateChoosers with the table and the sorter I use the following code as it is generated from the netbeans


Java Code:
org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, totalPaymentsTable, org.jdesktop.beansbinding.ELProperty.create("${rowSorter}"), jDateChooser1, org.jdesktop.beansbinding.BeanProperty.create("date"));
binding.setConverter(dateRowSorterConverter1);
bindingGroup.addBinding(binding);


org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, totalPaymentsTable, org.jdesktop.beansbinding.ELProperty.create("${rowSorter}"), jDateChooser2, org.jdesktop.beansbinding.BeanProperty.create("date"));
binding.setConverter(dateRowSorterConverter1);
bindingGroup.addBinding(binding);


dateRowSorterConverter1.setFrom(jDateChooser1);
dateRowSorterConverter1.setTable(totalPaymentsTable);
dateRowSorterConverter1.setTo(jDateChooser2);
Now when I try to run the program I get the following error:

run:
[TopLink Info]: 2011.03.06 04:15:41.730--ServerSession(1466238202)--TopLink, version: Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))
[TopLink Info]: 2011.03.06 04:15:42.116--ServerSession(1466238202)--file:/D:/Projects/CAM/build/classes/-cisPU login successful
6 Μαρ 2011 4:15:42 μμ org.jdesktop.application.Application$1 run
SEVERE: Application class cam.CAMApp failed to launch
org.jdesktop.beansbinding.PropertyResolutionExcept ion: Exception invoking method public void com.toedter.calendar.JDateChooser.setDate(java.uti l.Date) on com.toedter.calendar.JDateChooser[jDateChooser1,0,0,0x0,invalid,layout=java.awt.Bord erLayout,alignmentX=0.0,alignmentY=0.0,border=,fla gs=9,maximumSize=,minimumSize=,preferredSize=]
at org.jdesktop.beansbinding.BeanProperty.invokeMetho d(BeanProperty.java:791)
at org.jdesktop.beansbinding.BeanProperty.write(BeanP roperty.java:891)
at org.jdesktop.beansbinding.BeanProperty.setProperty (BeanProperty.java:909)
at org.jdesktop.beansbinding.BeanProperty.setValue(Be anProperty.java:580)
at org.jdesktop.beansbinding.Binding.refreshUnmanaged (Binding.java:1229)
at org.jdesktop.beansbinding.Binding.refresh(Binding. java:1207)
at org.jdesktop.beansbinding.AutoBinding.tryRefreshTh enSave(AutoBinding.java:162)
at org.jdesktop.beansbinding.AutoBinding.bindImpl(Aut oBinding.java:199)
at org.jdesktop.beansbinding.Binding.bindUnmanaged(Bi nding.java:959)
at org.jdesktop.beansbinding.Binding.bind(Binding.jav a:944)
at org.jdesktop.beansbinding.BindingGroup.bind(Bindin gGroup.java:143)
at cam.CAMView.initComponents(CAMView.java:1574)
at cam.CAMView.<init>(CAMView.java:46)
at cam.CAMApp.startup(CAMApp.java:19)
at org.jdesktop.application.Application$1.run(Applica tion.java:171)
at java.awt.event.InvocationEvent.dispatch(Invocation Event.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java: 597)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:122)
Caused by: java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jdesktop.beansbinding.BeanProperty.invokeMetho d(BeanProperty.java:782)
... 22 more
Exception in thread "AWT-EventQueue-0" java.lang.Error: Application class cam.CAMApp failed to launch
at org.jdesktop.application.Application$1.run(Applica tion.java:177)
at java.awt.event.InvocationEvent.dispatch(Invocation Event.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java: 597)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:122)
Caused by: org.jdesktop.beansbinding.PropertyResolutionExcept ion: Exception invoking method public void com.toedter.calendar.JDateChooser.setDate(java.uti l.Date) on com.toedter.calendar.JDateChooser[jDateChooser1,0,0,0x0,invalid,layout=java.awt.Bord erLayout,alignmentX=0.0,alignmentY=0.0,border=,fla gs=9,maximumSize=,minimumSize=,preferredSize=]
at org.jdesktop.beansbinding.BeanProperty.invokeMetho d(BeanProperty.java:791)
at org.jdesktop.beansbinding.BeanProperty.write(BeanP roperty.java:891)
at org.jdesktop.beansbinding.BeanProperty.setProperty (BeanProperty.java:909)
at org.jdesktop.beansbinding.BeanProperty.setValue(Be anProperty.java:580)
at org.jdesktop.beansbinding.Binding.refreshUnmanaged (Binding.java:1229)
at org.jdesktop.beansbinding.Binding.refresh(Binding. java:1207)
at org.jdesktop.beansbinding.AutoBinding.tryRefreshTh enSave(AutoBinding.java:162)
at org.jdesktop.beansbinding.AutoBinding.bindImpl(Aut oBinding.java:199)
at org.jdesktop.beansbinding.Binding.bindUnmanaged(Bi nding.java:959)
at org.jdesktop.beansbinding.Binding.bind(Binding.jav a:944)
at org.jdesktop.beansbinding.BindingGroup.bind(Bindin gGroup.java:143)
at cam.CAMView.initComponents(CAMView.java:1574)
at cam.CAMView.<init>(CAMView.java:46)
at cam.CAMApp.startup(CAMApp.java:19)
at org.jdesktop.application.Application$1.run(Applica tion.java:171)
... 8 more
Caused by: java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jdesktop.beansbinding.BeanProperty.invokeMetho d(BeanProperty.java:782)
... 22 more
BUILD SUCCESSFUL (total time: 3 seconds)
I dont use anywhere the setDate of the jDateChooser so I m totally lost. (I used it to set some initial values on the jDateChoosers but when I removed it I got the same error)

Any ideas on what I m doing wrong? (even another suggestion on how to implement the filter functionality of the table between the two dates)

I m using NetBeans to create this desktop application. If you need me to clarify something please let me know.

Thanks for your help