Search in sources :

Example 1 with MergedMarkup

use of org.apache.wicket.markup.MergedMarkup in project wicket by apache.

the class InheritedMarkupMarkupLoader method loadMarkup.

/**
 * Load the markup from the resource stream with the base MarkupLoader provided, than check if
 * markup inheritance must be applied. If yes, than load the base markup and merge them.
 */
@Override
public final Markup loadMarkup(final MarkupContainer container, final MarkupResourceStream markupResourceStream, final IMarkupLoader baseLoader, final boolean enforceReload) throws IOException, ResourceStreamNotFoundException {
    // read and parse the markup
    Markup markup = baseLoader.loadMarkup(container, markupResourceStream, null, enforceReload);
    // Check if markup contains <wicket:extend> which tells us that
    // we need to read the inherited markup as well.
    int extendIndex = requiresBaseMarkup(markup);
    if (extendIndex == -1) {
        return markup;
    }
    // Load the base markup
    final Markup baseMarkup = getBaseMarkup(container, markup, enforceReload);
    if ((baseMarkup == null) || (baseMarkup == Markup.NO_MARKUP)) {
        throw new MarkupNotFoundException("Base markup of inherited markup not found. Component class: " + markup.getMarkupResourceStream().getContainerInfo().getContainerClass().getName() + ". Enable debug messages for " + ResourceStreamLocator.class.getName() + " to get a list of all filenames tried.");
    }
    // Merge base and derived markup
    return new MergedMarkup(markup, baseMarkup, extendIndex);
}
Also used : Markup(org.apache.wicket.markup.Markup) MergedMarkup(org.apache.wicket.markup.MergedMarkup) MergedMarkup(org.apache.wicket.markup.MergedMarkup) ResourceStreamLocator(org.apache.wicket.core.util.resource.locator.ResourceStreamLocator) MarkupNotFoundException(org.apache.wicket.markup.MarkupNotFoundException)

Aggregations

ResourceStreamLocator (org.apache.wicket.core.util.resource.locator.ResourceStreamLocator)1 Markup (org.apache.wicket.markup.Markup)1 MarkupNotFoundException (org.apache.wicket.markup.MarkupNotFoundException)1 MergedMarkup (org.apache.wicket.markup.MergedMarkup)1