How to create DOM Element or Node from SafeHtml

596 views
Skip to first unread message

zixzigma

unread,
Feb 4, 2011, 1:53:44 AM2/4/11
to google-we...@googlegroups.com
GWT has Element and Node class which are wrappers for low level DOM elements/nodes.

do you know How I can convert SafeHtml to Element or Node ?

for example using the code below, I create a SafeHtml.

SafeHtml html = SafeHtmlUtils.fromSafeConstant("<tr><td>XXX</td><td>YYY</td></tr>");

but I could not find a way to create a Node or Element from this SafeHtml.
I could manipulate existing Node/Elements but not create one.

I want to add a new row to an existing table using Element/Node class.
therefore I need to create a new row, not manipulate an existing row.

do you have any idea how this can be possible ?

Thank You
Message has been deleted

Ryan Mehregan

unread,
Feb 4, 2011, 5:18:24 PM2/4/11
to google-we...@googlegroups.com
Please have a look at GWT DOM class:
http://google-web-toolkit.googlecode.com/svn/javadoc/2.1/com/google/gwt/user/client/DOM.html

DOM class has various static createElement factory methods that help you create any DOM element you want.

you can then use Element.setInnerHtml in conjunction with the SafeHtml you defined above.

Ryan
Reply all
Reply to author
Forward
0 new messages