2010-12-08 4 views
0

j-calais라는 API에서 결과를 얻은 다음 웹 페이지에 결과를 넣어 클라이언트의 모든 코드를 작성하지만 컴파일이 제대로되지 않습니다. 왜 몰라? 도와주세요. 다음과 같은 소스 코드 :GWT 클라이언트가 "throws Exception"문제를 일으키는 원인이 됨

이 명백한 오류가 발생하지이지만, 덕분에 ..... 성공적으로 많은 컴파일 될 캔트 :

공공 무효는 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() { 공공 무효 온 클릭 (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

가 발생하지 않습니다. –

답변

0

GWT는 체크되지 않은 예외를 처리 그래서 던질 수 있습니다 런타임 예외 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

관련 문제