I am attempting to convert an android app to a website using GWT. This was just an idea for a future-project.
What I want to do is mimic the Cursor function. I can do that just fine creating a class and just mimicking the functions I want to use.
But here is my issue: My UI finishes its code before the Cursor is fully initialized.
Here's how it works so far. I have the following code in my onModuleLoad, in my entrypoint:
Cursor cursor = databaseHelper.retrieveData("select * from '0-1'");
label.setText("Column-count: "+cursor.getColumnCount());
This outputs 0, because the entrypoint does not wait for my cursor-class to fully initialize.
My retrieveData method is here:
Cursor retrieveData(String query){
return new Cursor(query);
}
And my constructor in the Cursor-class is here
Cursor(String sql) {
greetingService = GWT.create(GreetingService.class);
columns = new ArrayList<>();
rows = new ArrayList<>();
currentPosition = -1;
greetingService.greetServer(sql, new AsyncCallback<List<List<String>>>() {
@Override
public void onFailure(Throwable caught) {}
@Override
public void onSuccess(List<List<String>> result) {
if (!result.isEmpty()) {
columns = result.get(0);
if (result.size() > 1) {
rows.addAll(result.subList(1, result.size()));
}
}
}
});
}
I have tried stopping the UI-activity with a while-loop waiting for a boolean to go from true to false (set to false in the onSuccess of the AsyncCallback), but the UI-activity is just locked and the site crashes.
Does somebody have a solution here?