Gnik
Gnik

Reputation: 7426

Print the particular GWT widget

I'm trying to print a GWT widget as follows,

String html = DOM.getElementById("id").getInnerHTML();


Print.it(html);

I'm not getting the entire html content of the widget. So i'm not able to print the expected result.

Can you help me? Or tell me the alternative way of printing a particular GWT widget from the view.

Thanks in advance, Gnik

Upvotes: 0

Views: 816

Answers (1)

SHiRKiT
SHiRKiT

Reputation: 1022

Well, it should print the HTML code. Calling DOM statically may generate 2 problems for you:

  • The ID you are trying to use isn't the right one. There is another element with the same ID and you are retrieving the element for that ID.
  • The ID you are using doesn't exist, as a framework may be changing this ID.

You can try to retrieve the HTML code with this widget.asWidget().getElement().getInnerHTML();

That should give you the correct HTML representation of the widget.

And make sure you are calling those methods after the elements are loaded (onLoad()) into the document, or you may recieve a JavaScriptException due to the element being null (check here for more info).

Upvotes: 3

Related Questions