1. HTMLTemplateWidget replace tag with enterd id from html file,
HTMLPanel insert it into enclosing tag with specified id/
And here is advantage of HTMLTemplateWidget:
for example you want insert two buttons in <td></td> in order button1
and after it button2
a) with HTMLPanel you will write something like this:
<table>
<tr><td id="buttons"></td></tr> ---- innerHTML
</table>
and then
HTMLPanel panel = new HTMLPanel(innerHTML);
panel.add(new Button("button1"),"buttons");
panel.add(new Button("button2"),"buttons");
notice that you MUST use add() method in this order and can write
panel.add(new Button("button2"),"buttons");
panel.add(new Button("button1"),"buttons");
other way is
<table>
<tr><td ><div id="button1"></div><div id="button2"></div></td></
tr> ---- innerHTML
</table>
HTMLPanel panel = new HTMLPanel(innerHTML);
panel.add(new Button("button1"),"button1");
panel.add(new Button("button2"),"button2");
here we have more flexebility, but have to write two unneeded in
design div tags.
b) with HTMLTemplateWidget you replace already existed tag with
specified id and you can put it anywhere like
<table>
<tr><td ><input type="button" id="button1"></input><input
type="button" id="button2"></input></td></tr> ---- test.html
</table>
HTMLTemplateWidget template = new HTMLTemplateWidget("test.html")
template.addWidget("button1",new Button("button1"));
template.addWidget("button2",new Button("button2"));
order of adding of Button Widgets doesn't metter, and you do not need
to write unneeded html tags(two input tags are part of true design and
even helps designer to work with HTML)
2. You can write inline css and style names in you html file and
HTMLTemplateWidget will reset it to widget itself! Now you do not need
use setStyleName and addStyleName methods in your JAVA code!
3. You can replace already added widget by newone like
<table>
<tr><td ><input type="button" id="button1"></input></td></tr>
---- test.html
</table>
HTMLTemplateWidget template = new HTMLTemplateWidget("test.html")
template.addWidget("button1",new Button("button1"));
.....
template.addWidget("button1",new Button("button2"));
in HTMLPanel there is no this like functionallity
4. HTML content which you pass in HTMLPanel doesn't look like real
html design file, becouse all input just will be added and in start it
is empty, it complicate work with such "empty" HTML for designers.
With HTMLTemplateWidget, html file looks exactly like design you want
and it simplify work with it for designers, thay work with it like
with simple html, only thing they must remember, DO NOT TOUCH id
attributes.
5. HTMLTemplateWidget supports id scoups. It means if you use two
HTMLTemplateWidgets you can use duplicated ids in different
HTMLTemplateWidgets widget, which is not allowed in HTMLPanel
6. Passing HTML content is a very bad solution, as for me, passing
file name is much more better.
Thanks