cpanel.setBodyStyleName("pad-text");
final Html html = new Html();
html.setStyleName("pad-text");
final TextArea area = new TextArea();
area.setSize(485, 150);
toolBar = new ToolBar();
toolBar.add(new Button("Apply Template", new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
String template = area.getValue();
XTemplate tpl = XTemplate.create(template);
tpl.overwrite(html.getElement(), Util.getJsObject(person, 3));
}
}));
cpanel.setTopComponent(toolBar);
StringBuilder sb = new StringBuilder();
sb.append("<p>Name: {name}</p>\r\n");
sb.append("<p>Company: {company}</p>\r\n");
sb.append("<p>Location: {location}</p>\r\n");
sb.append("<p>Salary: {income:currency}</p>\r\n");
sb.append("<p>Kids:</p>\r\n");
sb.append("<tpl for=\"kids\" if=\"name==\'Darrell Meyer\'\">\r\n");
sb.append("<tpl if=\"age > 1\"><p>{#}. {parent.name}\'s kid - {name} - {bday:date(\"M/d/yyyy\")}</p></tpl>");
sb.append("</tpl>\r\n");
area.setValue(sb.toString());
cpanel.add(area);
cpanel.add(html);
vp.add(panel);
vp.add(xpanel);