2012-11-09 2 views
0

Gxt의 디자이너 작업에서 HTML 코드를 통합 할 때 문제가 발생하므로 매우 간단한 테스트를 실행하고 Gtml HtmlPanel을 사용하기 시작했습니다. 이유는 설명 할 수 없습니다. 포함 된 자바 스크립트가 렌더링되지 않습니다.GWT & GXT Problesm with Html fragment

내가 (나는 개똥 벌레로 보았다) 브라우저에서 자바 스크립트 함수를 찾을 수는 응답 또는 조언에 누군가가

public class TestHTML implements EntryPoint { 

    public void onModuleLoad() { 

     String contenu = "<html>" 
     +"<head>" 
     +" <script type='text/javascript'>" 
     +"function functionOne() { alert('You clicked the top text'); }" 
     +"function functionTwo() { alert('You clicked the bottom text'); }" 
     +"</script>" 
     +"</head>" 
     +"<body>" 
     +"<p><a href='#' onClick='functionOne();'>Top Text</a></p>" 
     +"<p><a href='javascript:functionTwo();'>Bottom Text</a></p>" 
     +"</body>" 
     +"</html>"; 
      HTMLPanel htmlPanel = new HTMLPanel(contenu); 
      ContentPanel content = new ContentPanel(); 
      content.add(htmlPanel); 
      RootPanel.get().add(content); 

    } 
} 
을 거기에 ? 감사합니다.

답변

2

gwt에서 JSNI를 사용해야합니다.

public void onModuleLoad() { 
    registerJS(); 
    String contenu = "<html>" 
      +"<body>" 
      +"<p><a href='#' onClick='functionOne();'>Top Text</a></p>" 
      +"<p><a href='javascript:functionTwo();'>Bottom Text</a></p>" 
      +"</body>" 
      +"</html>"; 
       HTMLPanel htmlPanel = new HTMLPanel(contenu); 
       RootPanel.get().add(htmlPanel); 
} 

public native void registerJS()/*-{ 
    $wnd.functionOne = function(){ 
     alert('you clicked the top text'); 
    } 

    $wnd.functionTwo = function(){ 
     alert('you clicked the bottom text'); 
    } 
}-*/; 
+0

고맙습니다. 내 문제는 원래 더 복잡했기 때문에 귀하의 정보에서 시작해야합니다. 우편으로 연락 할 수있는 방법이 있습니까? –

+0

는 내 프로필에 몇 가지 연락처 정보를 추가했습니다 :-) – David