Example usage for org.apache.wicket.markup ComponentTag isAutoComponentTag

List of usage examples for org.apache.wicket.markup ComponentTag isAutoComponentTag

Introduction

In this page you can find the example usage for org.apache.wicket.markup ComponentTag isAutoComponentTag.

Prototype

public boolean isAutoComponentTag() 

Source Link

Usage

From source file:org.efaps.ui.wicket.components.AbstractParentMarkupContainer.java

License:Apache License

/**
 * @see org.apache.wicket.MarkupContainer#onRender(org.apache.wicket.markup.MarkupStream)
 *///ww  w .  j a  v a  2 s  .c o m
@Override
public void onRender() {
    final IMarkupFragment markup = getMarkup();
    final MarkupStream markupStream = new MarkupStream(markup);
    final int markupStart = markupStream.getCurrentIndex();

    // Get mutable copy of next tag
    final ComponentTag openTag = markupStream.getTag();
    final ComponentTag tag = openTag.mutable();

    // Call any tag handler
    onComponentTag(tag);

    // Render open tag
    if (!getRenderBodyOnly()) {
        renderComponentTag(tag);
    }
    markupStream.next();

    // Render the body only if open-body-close. Do not render if
    // open-close.
    if (tag.isOpen()) {
        // Render the body
        onComponentTagBody(markupStream, tag);
    }
    markupStream.setCurrentIndex(markupStart);

    final Iterator<?> childs = this.iterator();
    while (childs.hasNext()) {
        markupStream.setCurrentIndex(markupStart);
        final Component child = (Component) childs.next();
        child.rendered();
    }

    markupStream.setCurrentIndex(markupStart);
    markupStream.next();
    // Render close tag

    if (tag.isOpen()) {
        if (openTag.isOpen()) {
            // Get the close tag from the stream
            ComponentTag closeTag = markupStream.getTag();

            // If the open tag had its id changed
            if (tag.isAutoComponentTag()) {
                // change the id of the close tag
                closeTag = closeTag.mutable();
                closeTag.setName(tag.getName());
            }

            // Render the close tag
            renderComponentTag(closeTag);
            markupStream.next();
        }
    }
}