I am having some problems with events in a subclass of a widget.
I have a SortableCheckBox class below:
--------------------------------------------------------------------------------------------------------
import com.google.gwt.user.client.ui.CheckBox;
public class SortableCheckBox extends CheckBox implements Comparable
{
public SortableCheckBox()
{
super();
}
public SortableCheckBox(String label)
{
super(label);
}
public SortableCheckBox(String label, boolean asHTML)
{
super(label, asHTML);
}
public int compareTo(Object arg0)
{
return 0;
}
}
---------------------------------------------------------------------------------------------
I have add this checkbox to a sortable table:
sortableTable.addValue(0, 1, sortableCheckBox);
When I deploy this and check the checkbox,
sortableCheckBox.isChecked() returns false
It's as if the sortableCheckBox never gets the event that the CheckBox
is checked.
Am i missing something in the subclass implementation?
Any ideas??
Thanks!
Jen.
Can you avoid the problem by using Comparator? Instead of using a
subclass CheckBox that implements Comparable, why not use CheckBox and
an instance of Comparator? It should be just as "sortable", but
without the problems you've run into.
Ian
--
Tired of pop-ups, security holes, and spyware?
Try Firefox: http://www.getfirefox.com
Thanks for the reply.
The reason I'm implementing Comparable is because i'm using a sortable
table I got here:
http://psthapar.googlepages.com/simplesortabletable
this requires that entries that i want to be sorted implement
Comparable.
any suggestions around this?
Thanks!
Jen.
It looks to me like the code you linked to doesn't do what you want.
When it renders the table, it assumes that the values you've added to
the table can all be drawn with "toString()". This assumption is
false for widgets, including CheckBox. Even if you could solve your
event problem, you'll run into issues when you add a SortableCheckBox
to a SortableTable.
You'll either have to change the code (it's under the LGPL, so that
> You'll either have to change the code (it's under the LGPL, so that
may mean distributing your changes, depending on your circumstances),
ask the original author to change the code, or find another way to do
what you want.
Ian