Ejemplo n.º 1
0
  private void loadData() {
    // Set up the callback object.
    AsyncCallback<AccountInfo[]> callback =
        new AsyncCallback<AccountInfo[]>() {
          public void onFailure(Throwable caught) {
            // TODO: Do something with errors.
            GWT.log(caught.toString());
            refreshBtn.setEnabled(true);
          }

          public void onSuccess(AccountInfo[] info) {
            if (info == null) {
              Window.alert(MockStock.SESSION_TIMEOUT_MSG);
              return;
            }
            populateRankTable(info);
            refreshBtn.setEnabled(true);

            String time =
                "最后更新时间: "
                    + DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_SHORT)
                        .format(new Date())
                    + " "
                    + DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.TIME_MEDIUM)
                        .format(new Date());
            lastModified.setText(time);
            hp.add(lastModified);
            hp.setCellHorizontalAlignment(lastModified, ALIGN_RIGHT);
            hp.setCellVerticalAlignment(lastModified, ALIGN_BOTTOM);
          }
        };
    // Make the call to the stock price service.
    stockSvc.getAllAccountInfo(callback);
  }