Search in sources :

Example 1 with BorderMarkupSourcingStrategy

use of org.apache.wicket.markup.html.panel.BorderMarkupSourcingStrategy in project wicket by apache.

the class Border method getMarkup.

/**
 * Search for the child markup in the file associated with the Border. The child markup must in
 * between the <wicket:border> tags.
 */
@Override
public IMarkupFragment getMarkup(final Component child) {
    // Border require an associated markup resource file
    IMarkupFragment markup = getAssociatedMarkup();
    if (markup == null) {
        throw new MarkupException("Unable to find associated markup file for Border: " + this.toString());
    }
    // Find <wicket:border>
    IMarkupFragment borderMarkup = null;
    for (int i = 0; i < markup.size(); i++) {
        MarkupElement elem = markup.get(i);
        if (TagUtils.isWicketBorderTag(elem)) {
            borderMarkup = new MarkupFragment(markup, i);
            break;
        }
    }
    if (borderMarkup == null) {
        throw new MarkupException(markup.getMarkupResourceStream(), "Unable to find <wicket:border> tag in associated markup file for Border: " + this.toString());
    }
    // If child == null, return the markup fragment starting with the <wicket:border> tag
    if (child == null) {
        return borderMarkup;
    }
    // Is child == BorderBody?
    if (child == body) {
        // Get the <wicket:body> markup
        return body.getMarkup();
    }
    // Find the markup for the child component
    IMarkupFragment childMarkup = borderMarkup.find(child.getId());
    if (childMarkup != null) {
        return childMarkup;
    }
    return ((BorderMarkupSourcingStrategy) getMarkupSourcingStrategy()).findMarkupInAssociatedFileHeader(this, child);
}
Also used : BorderMarkupSourcingStrategy(org.apache.wicket.markup.html.panel.BorderMarkupSourcingStrategy) MarkupFragment(org.apache.wicket.markup.MarkupFragment) IMarkupFragment(org.apache.wicket.markup.IMarkupFragment) IMarkupFragment(org.apache.wicket.markup.IMarkupFragment) MarkupElement(org.apache.wicket.markup.MarkupElement) MarkupException(org.apache.wicket.markup.MarkupException)

Aggregations

IMarkupFragment (org.apache.wicket.markup.IMarkupFragment)1 MarkupElement (org.apache.wicket.markup.MarkupElement)1 MarkupException (org.apache.wicket.markup.MarkupException)1 MarkupFragment (org.apache.wicket.markup.MarkupFragment)1 BorderMarkupSourcingStrategy (org.apache.wicket.markup.html.panel.BorderMarkupSourcingStrategy)1