I am trying to display a formatted xml output in a Tab widget in GWT. What I tried is the following:
final Tab myTab = new Tab("MyTab");
String instanceUrl = "someUrl/someXml.xml";
final HTMLPane dataPane = new HTMLPane();
dataPane.setContentsURL(instanceUrl);
dataPane.setContentsType(ContentsType.PAGE);
dataPane.setPane(dataPane);
What I am getting is an empty tab. Nothing is visualized but when I click on the page, the “View source” is displaying my XML in the way I want to see it in the tab.
Does anyone have any suggestions about it?
Thanks!
Don’t do GWT yet. Try doing it on an HTML page.
Create a blank .html file (not a .xml) file as a local file.
In the body of the html page, place the whole bunch of XML stuffs you wanted to display.
Then click the local html file you just created, to display it on the browser.
Voila! The XML does not display.
Why?
All your tag brackets “<” and “>” must be encoded/escaped to tell the html pane that they are not HTML/XML of the page/pane but are meant to be displayed as-is.
In GWT, use an encoding method from this class:
http://google-web-toolkit.googlecode.com/svn/javadoc/2.4/com/google/gwt/safehtml/shared/SafeHtmlUtils.html.