2014-02-10 28 views
0

我有HTMLPanel,我想將文本設置爲一些XML文件內容。我如何做到這一點?也許使用<ui:with type="com.blablblba.Filename.xml" field="conent"/>如何從xml設置uibinder文本

例如:我有Widget.ui.xml 它包含了諸如

<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder' 
      xmlns:g="urn:import:com.google.gwt.user.client.ui" 
       > 
    <ui:style> 
    </ui:style> 

    <g:VerticalPanel spacing="10"> 
     <panel:ContentPanel collapsible="true" height="300px" width="150px"></panel:ContentPanel> 
     <panel:ContentPanel width="100%"> 
      <g:HTMLPanel ui:field="xmlInfo"> 
      </g:HTMLPanel> 
     </panel:ContentPanel> 
    </g:VerticalPanel> 

</ui:UiBinder> 

一些代碼,我想在另一個小部件使用UiBinder的

+0

你想達到什麼做的。你可以提供你需要幫助的Ui聯編程序代碼 – Onkar

+0

添加我想要的示例 –

回答

0

我懷疑你的文本顯示驗證碼可以直接做到這一點。您將需要利用RequestBuilder

new RequestBuilder(Method.GET, "xmlPath").sendRequest("", new RequestCallback() { 
    @Override 
    public void onResponseReceived(Request req, Response resp) { 
    String text = resp.getText(); 
    // do stuff with the text 
    } 

    @Override 
    public void onError(Request res, Throwable throwable) { 
    // handle errors 
    } 
}); 
+1

emm ...我可以通過TextResource.getText() –

2

我還沒有嘗試過這種方法,但我認爲它可能工作。

創建TextResource文件(即myTextFile)。

聲明它UiBinder的:

<ui:with field="content" type="com.blablblba.myTextFile" /> 

然後使用它像:

<g:HTMLPanel ui:field="xmlInfo"> 
    <ui:text from="{content.getText}" /> 
</g:HTMLPanel>