}
//-- ListitemRendererExt --//
public Listitem newListitem(Listbox listbox) {
//clone from template
final Listitem clone = (Listitem)_template.clone();
//TODO: see if databinder has this kind of Listitem, if not, add new CollectionListItem
//avoid duplicate id error, will set to new id when render()
//Bug #1962153: Data binding generates duplicate id in some case (add "_")
if (clone.getId().length() > 0) {
clone.setId(null);
}
//link cloned component with template
//each Listitem and and it decendants share the same templatemap
Map templatemap = new HashMap(7);
linkTemplates(clone, _template, templatemap);
//link this template map to parent templatemap (Listbox in Listbox)
Map parenttemplatemap = (Map) listbox.getAttribute(DataBinder.TEMPLATEMAP);
if (parenttemplatemap != null) {
templatemap.put(DataBinder.TEMPLATEMAP, parenttemplatemap);
}
//kept clone kids somewhere to avoid create too many components in browser
final List kids = new ArrayList(clone.getChildren());
clone.setAttribute(KIDS, kids);
clone.getChildren().clear();
return clone;
}