PDA

View Full Version : XTemplate - List<String>



diegolovison
4 Jan 2011, 12:29 PM
MyModel.java


private String name;
private List<String> products;


How I can implement a XTemplate that can iterate on a List<String> ?

I try...


private String getTemplate() {

final StringBuilder sb = new StringBuilder();

sb.append("<p>Name: {name}</p>");
sb.append("<tpl for='products'>");
sb.append("<tpl>{value}</tpl>"); // of course that it is wrong....
sb.append("</tpl>");

return sb.toString();
}

only the name appears...

thanks

cimballi
4 Jan 2011, 3:26 PM
Look here : http://www.sencha.com/examples/explorer.html#templates
You can see that templates provide for and if statements.

diegolovison
5 Jan 2011, 4:13 AM
thanks... but dont have one example that use List<String>...
.....


Client


private String name;
private List<Customer> customers;


Customer


private String name;


using rowExpander


final XTemplate tpl = XTemplate.create("<tpl for='customers'><tpl>{name}</tpl></tpl>");

RowExpander expander = new RowExpander();
expander.setTemplate(tpl);


but dont work.....

how I can iterate in one list using XTemplate on RowExpander?

thanks

diegolovison
5 Jan 2011, 4:51 AM
one day to discovery that

'customers' should be \"customers\"
so work ;)