MarkupRenderer renderer = new MarkupRenderer(markup.items, markup.doctype) {
@Override
void postprocessTagAttributes(Tag tag, Map<String, String> attributes) {
// if during rendering we have a ComponentTag
if (tag instanceof ComponentTag && tag.getType() != Tag.Type.CLOSE) {
ComponentTag componentTag = (ComponentTag) tag;
String id = getComponentID(componentTag);
// check if the component already is in hierarchy
if (getExistingComponents().contains(id)) {
// just put the wicket:id attribute to component tag
attributes.put("wicket:id", id);
components.add(id);
} else {
// otherwise we need to create the component instance
Component c = componentTag.getComponent(id, component.getModel());
if (c != null) {
attributes.put("wicket:id", id);
components.add(id);
((MarkupContainer) component).add(c);
}