Move Screen RPC calls into the onLoad method

By making the RPC call during onLoad we ensure the screen is actually
attached to the browser window, and thus has a good chance of wanting
to get its data from the server.

Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2008-11-27 17:05:27 -08:00
parent 319f44e754
commit 649f83eede
3 changed files with 24 additions and 14 deletions

View File

@@ -22,6 +22,7 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
public class MineScreen extends AccountScreen {
private Account.Id ownerId;
private ChangeTable table;
private ChangeTable.Section byOwner;
private ChangeTable.Section forReview;
@@ -34,27 +35,33 @@ public class MineScreen extends AccountScreen {
public MineScreen(final Account.Id id) {
super(Util.C.mineHeading());
ownerId = id;
table = new ChangeTable();
byOwner = new ChangeTable.Section(Util.C.mineByMe());
forReview = new ChangeTable.Section(Util.C.mineForReview());
closed = new ChangeTable.Section(Util.C.mineClosed());
Util.LIST_SVC.forAccount(id, new AsyncCallback<AccountDashboardInfo>() {
public void onSuccess(final AccountDashboardInfo r) {
byOwner.display(r.getByOwner());
forReview.display(r.getForReview());
closed.display(r.getClosed());
}
public void onFailure(final Throwable caught) {
GWT.log("Fail", caught);
}
});
table.addSection(byOwner);
table.addSection(forReview);
table.addSection(closed);
add(table);
}
@Override
public void onLoad() {
super.onLoad();
Util.LIST_SVC.forAccount(ownerId,
new AsyncCallback<AccountDashboardInfo>() {
public void onSuccess(final AccountDashboardInfo r) {
byOwner.display(r.getByOwner());
forReview.display(r.getForReview());
closed.display(r.getClosed());
}
public void onFailure(final Throwable caught) {
GWT.log("Fail", caught);
}
});
}
}

View File

@@ -28,7 +28,6 @@ public class MineStarredScreen extends AccountScreen {
starred = new ChangeTable.Section();
table.addSection(starred);
add(table);
}
}