I use the GWT CellList widget to render Cell elements.
Is there a way to register a render complete or render done event to execute stuff after rendering was done?
I had the same question and taking a look into the code I have found a possible solution.
In the HasDataPresenter
there are the code which renders the cells into the view (method resolvePendingState(JsArrayInteger modifiedRows)
:
if (redrawRequired) {
// Redraw the entire content.
SafeHtmlBuilder sb = new SafeHtmlBuilder();
view.replaceAllChildren(newState.rowData, selectionModel, newState.keyboardStealFocus);
view.resetFocus();
} else if (range0 != null) {
// Surgically replace specific rows.
// Replace range0.
{
int absStart = range0.getStart();
int relStart = absStart - pageStart;
SafeHtmlBuilder sb = new SafeHtmlBuilder();
List<T> replaceValues = newState.rowData.subList(relStart, relStart + range0.getLength());
view.replaceChildren(replaceValues, relStart, selectionModel, newState.keyboardStealFocus);
}
// Replace range1 if it exists.
if (range1 != null) {
int absStart = range1.getStart();
int relStart = absStart - pageStart;
SafeHtmlBuilder sb = new SafeHtmlBuilder();
List<T> replaceValues = newState.rowData.subList(relStart, relStart + range1.getLength());
view.replaceChildren(replaceValues, relStart, selectionModel, newState.keyboardStealFocus);
}
view.resetFocus();
The method view.replaceAllChildren(....) calls to render cell's render method, and when it has finished a ValueChangeEvent() is fired.
@Override
public void replaceAllChildren(....) {
SafeHtml html = renderRowValues(...);
....
fireValueChangeEvent();
}
So in your cellList you should do something like:
cellList.addHandler(new ValueChangeHandler<List<IPost>>() {
@Override
public void onValueChange(ValueChangeEvent<List<IPost>> event) {
//Do something
//Be careful because this handler could be called from other methods
}
}, ValueChangeEvent.getType());