2010-12-08 48 views
0

我尝试使用从API称J-加莱得到结果,然后出来把结果在网页上,我写在客户端的所有代码,但它不能编译权,不知道为什么?请帮忙。源代码象下面这样:GWT客户端“抛出异常”的原因compling问题

有出现没有明显的错误,但它不能是成功编译.....非常感谢:

公共无效onModuleLoad(){// 创建库存数据表。 stocksFlexTable.setText(0,0,“Type”); 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); 

//在添加按钮上监听鼠标事件。 addStockButton.addClickHandler(新clickHandler事件(){ 公共无效的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")); 
      } 

}

}

+2

请加上你,这将有助于回答你的问题的错误。 – 2010-12-08 14:32:33

回答

0

GWT只处理unchecked异常所以你可以扔运行时间Exceptio NS

或写自己的异常是从运行时异常扩展那么就不会造成任何编译时间问题

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 
+0

它迫使我抛出IOException ... – Camellia 2010-12-15 21:05:09

相关问题