Mike Voitenko
Mike Voitenko

Reputation: 133

How to set uibinder text from xml

I have HTMLPanel, and I want to set as text there some XML-file content. How I can do this? Maybe using <ui:with type="com.blablblba.Filename.xml" field="conent"/> ?

For example : I have Widget.ui.xml And it contains some code like

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

And I want to display this code on another widget as a text using UiBinder

Upvotes: 0

Views: 1043

Answers (2)

Andrei Volgin
Andrei Volgin

Reputation: 41089

I have not tried this approach, but I think it might work.

Create a TextResource file (i.e. myTextFile).

Declare it in UiBinder:

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

Then use it like:

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

Upvotes: 2

Onkar
Onkar

Reputation: 662

I doubt you can do that directly. You will need to make use of 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
  }
});

Upvotes: 0

Related Questions