AsyncDataProvider for a CellTable that must always have an item selected

114 views
Skip to first unread message

Tiago Rinck Caveden

unread,
Jul 5, 2012, 10:02:50 AM7/5/12
to google-we...@googlegroups.com
Hello,

I'm writing a custom Composite widget which contains a CellTable. This CellTable must always have an item selected. (I wrote an implementation of DefaultSelectionModel to achieve that). And every time the selection changes, a specific SelectionEventHandler must be invoked to perform some modifications in the widget - modifications which depend on the selected element.

This CellTable must be populated with an AsynDataProvider which is given by "user code", so I can't really change it to adapt to my widget "internals".

How can I make sure that the selection model will fire a SelectionChangeEvent every time the range changes and the new data is asynchronously set by the provider?
The main problem here is that my SelectionEventHandler must be executed after the asynchronous request completes, because it depends on the data loaded from the server. If I simply add another RangeChangeHandler to the CellTable, even if I add it after the one added by the AsyncDataProvider, that is not enough because it is likely to execute before the call to the server returns.

I saw there's an addValueChangeHandler on AbstractHasData, which could help me I guess, but unfortunately it is package protected, and the javadoc gives the impression it only works for CellBrowser, not CellTable.

Anyone has any idea that could help me?
If there was a way to add a handler that would react after the AsyncDataProvider calls updateRowData that would be great...

Thank you very much,
--
Tiago Rinck Caveden

Ümit Seren

unread,
Jul 7, 2012, 5:34:16 AM7/7/12
to google-we...@googlegroups.com
Why don't you override the updateRowData method of your custom CellTable to fire the SelectionChangedEvent?
The AsyncDataProvider will call updateRowData and this will call it on all attached displays thus also your custom CellTable.

Tiago

unread,
Jul 9, 2012, 4:10:35 AM7/9/12
to google-we...@googlegroups.com
Ümit,

That's exactly what I've done. I've overridden the method setRowData(int, List<T) of my internal CellTable since I have control over that instance.

But what if I had not? Like, what if the CellTable instance was a parameter or something?

Wouldn't it be interesting if HasData allowed the addition of another event type, one that would be fired after the table contents are changed?
Should I open an enhancement issue? 
Reply all
Reply to author
Forward
0 new messages