ggeorg / gwt-mosaic

Automatically exported from code.google.com/p/gwt-mosaic
1 stars 0 forks source link

ListModel interface lacks a "getIndexOfElement" method, causing usage issues and bugs #73

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Steps to reproduce the problem:
1. Open Showcase -> ListBox -> Multi Column ListBox tab
2. Reorder the elements (click "name" column header to change the sorting)
3. Select the first row ("Holger Adams"), and press "Edit"
4. Change name to "Holger Adams1" and press "OK"

Expected - the row with "Holger Adams" should contain "Holger Adams1"
Instead you see the fourth row changed to "Holger Adams1"

This applies to gwt-mosaic-0.4.0-rc4

THIS IS NOT JUST A SHOWCASE ISSUE - this is an issue with the ListModel
interface which does not allow us to fix this bug.

This is caused by the fact that we use the listBox.getSelectedIndex() to
get the index of the selected table row, but then we use model.set(index,
input) to change the value in the model. Unfortunately the two indexes (the
listBox index and the ListModel index) become out of synch when we resort
the elements in the listBox. 
We can work around this limitation when we DELETE items, because in the
model you can do remove by item itself - listBox.getModel().remove(item) --
however we cannot work around this gracefully for EDIT actions, because we
need to know the actual model index of the element.

This means that the model either needs to implement a
getIndexOfElement(item) or a set(item, newItem) method.

Original issue reported on code.google.com by eugine...@gmail.com on 30 Mar 2010 at 3:59

GoogleCodeExporter commented 9 years ago
Hi,

it is not only a problem when you want to edit data - I use the ListBox in a 
Popup
for the results of a search. In the edit view of the application you can go 
through
the result list with "next" and "prev" buttons. A click on a button fires an 
event
and the list widgets listen to it and loads the next item for edit. 

But when you do a sort in the ListBox the actual item is out of sync and I cant 
find
a handler to catch the sort event and to sync the values again.

I can set an comparator but it is called for every item in the list - what I 
need is
an event that is fired when the list is sorted.

Anybody with an idea?

Thanks

Original comment by kars...@porkypie.de on 4 May 2010 at 11:38