Domanda

Io cerco di conseguenza utilizzare Get da un'API chiamata J-Calais, e poi fuori mettere il risultato in una pagina web, scrivo tutto il codice client, ma posso compilare bene, non so perché ??? per favore aiuto. il codice sorgente come di seguito:

non v'è alcun errore evidente sorgere, ma non posso essere di compilazione con successo ..... grazie mille:

onModuleLoad public void () {     // Crea una tabella per i dati di stock.     stocksFlexTable.setText (0, 0, "Tipo");     stocksFlexTable.setText (0, 1, "Nome");

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

// Ascolta per gli eventi del mouse sul pulsante Aggiungi.     addStockButton.addClickHandler (nuova clickHandler () {       public void onClick (evento 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"));
          }

}

}

È stato utile?

Soluzione

GWT solo maniglie eccezioni unchecked in modo da poter gettare Eccezioni runtime

o lascia la tua Eccezione che estende dal Runtime Exception allora non causa alcun problema di tempo di compilazione

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
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top