I am developing an GWT app and when user clicks on button, form panel with checkboxes should appear. Those checkboxes should be filled with list of items from async service. But when I open form panel I dont have those checkboxes. I debugged and saw that result from my service is not here on time, but later list is full.. Here is the code:
@Override
public void createBody() {
GWT_ACCESS_ROLE_SERVICE.findByUserId(null, currentSession.getSelectedAccount().getId(), userId, new AsyncCallback<PagingLoadResult<GwtAccessRole>>() {
@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
}
@Override
public void onSuccess(PagingLoadResult<GwtAccessRole> result) {
lista = result.getData();
for (GwtAccessRole gwtAccessRole : lista) {
bb = new CheckBox();
bb.setBoxLabel(gwtAccessRole.getRoleName());
}
FormPanel roleFormPanel = new FormPanel(FORM_LABEL_WIDTH);
roleFormPanel.add(bb);
bodyPanel.add(roleFormPanel);
}
});
}
What am I doing wrong and why my checkboxes are not filled? Thanks in advance.
EDIT: When I debug, this method GWT_ACCESS_ROLE_SERVICE.findByUserId is shown AFTER Form Panel appears. So Form Panel apperas and after that debug goes to this my method and does all the stuff.
It should look something like this then:
.gwt.xml module will have these lines added:
You were not adding anything to the form panel as the checkbox had gone out of scope.
EDIT: added logging output information