0

j-calais という API から結果を取得しようとして、その結果を Web ページに出力しようとしました。すべてのコードをクライアントに記述しましたが、正しくコンパイルできません。理由がわかりません。助けてください。以下のようなソースコード:

明らかなエラーは発生しませんが、正常にコンパイルできません.....どうもありがとうございました:

public void onModuleLoad() { // 株式データのテーブルを作成します。stocksFlexTable.setText(0, 0, "タイプ"); stocksFlexTable.setText(0, 1, "名前");

// Assemble Add Stock panel.
addPanel.add(newSymbolTextBox);
addPanel.add(addStockButton);

// Assemble Main panel.
mainPanel.add(stocksFlexTable);
mainPanel.add(addPanel);
mainPanel.add(lastUpdatedLabel);

// Associate the Main panel with the HTML host page.
RootPanel.get("stockList").add(mainPanel);

// Move cursor focus to the input box.
newSymbolTextBox.setFocus(true);

// [追加] ボタンでのマウス イベントをリッスンします。addStockButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent イベント) {

                        try {
                            addStock();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }

  }
});
// Listen for keyboard events in the input box.
newSymbolTextBox.addKeyPressHandler(new KeyPressHandler() {
  public void onKeyPress(KeyPressEvent event) {
    if (event.getCharCode() == KeyCodes.KEY_ENTER) {  
            try {
                addStock();
            } catch (Exception e) {
                e.printStackTrace();
            }
  }
  }
});

}

private void addStock() throws Exception {
  final String url_s = newSymbolTextBox.getText().toUpperCase().trim();
  newSymbolTextBox.setFocus(true);
  newSymbolTextBox.setText("");
  int row = stocksFlexTable.getRowCount();


  CalaisClient client = new CalaisRestClient("ysw5rx69jkvdnzqf6sgjduqj");
    System.out.print("read success...\n");
     URL url = new URL(url_s);    
     CalaisResponse response = client.analyze(url);         
        for (CalaisObject entity : response.getEntities()) {
            System.out.println(entity.getField("_type") + ":" 
                               + entity.getField("name"));
            stocks.add(entity.getField("_type"));
            stocksFlexTable.setText(row, 0, entity.getField("_type"));
            stocksFlexTable.setText(row, 1, entity.getField("name"));
          }

        for (CalaisObject topic : response.getTopics()) {
            System.out.println(topic.getField("categoryName"));
          }

}

}

4

1 に答える 1

0

GWT は未チェックの例外のみを処理するため、ランタイム例外をスローできます

または、ランタイム例外から拡張された独自の例外を作成すると、コンパイル時の問題は発生しません

void f() throws NullPointerException // will not cause any problem because it is Runtime exception so unchecked

void f() throws IllegalAccessException // it is checked exception so there will be problem at compile time
于 2010-12-08T19:21:21.623 に答える