Frage

Ich versuche, verwenden zu resultieren aus einem api j-calais genannt, und dann lösche das Ergebnis auf einer Web-Seite, ich alle den Code in Client schreiben, aber es kann nicht kompilieren rechts, weiß nicht, warum ??? bitte Hilfe. der Quellcode wie folgt:

gibt es keinen offensichtlichen Fehler auftreten, aber es kann nicht Kompilierung erfolgreich sein ..... vielen Dank:

public void onModuleLoad () { // Erstellen Tabelle für Bestandsdaten. stocksFlexTable.setText (0, 0, "Typ"); stocksFlexTable.setText (0, 1, "Name");

// 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);

// Hören für Mausereignisse auf die Schaltfläche Hinzufügen. addStockButton.addClickHandler (neu clickhandler () { public void onClick (ClickEvent event) {

                        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"));
          }

}

}

War es hilfreich?

Lösung

GWT only handles unchecked exceptions so you can throw Runtime Exceptions

or write your own Exception that extends from Runtime Exception then it will not cause any compile time problem

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
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top