Search in sources :

Example 1 with ResolverFilter

use of org.apache.wicket.markup.resolver.ComponentResolvers.ResolverFilter in project wicket by apache.

the class Enclosure method getChildComponent.

/**
 * Resolves the child component which is the controller of this Enclosure
 *
 * @param markupStream
 *            the markup stream of this Enclosure
 * @param enclosureParent
 *            the non-auto parent component of this Enclosure
 * @return The component associated with the {@linkplain #childId}
 */
private Component getChildComponent(final MarkupStream markupStream, MarkupContainer enclosureParent) {
    String fullChildId = getChildId();
    Component controller = enclosureParent.get(fullChildId);
    if (controller == null) {
        int orgIndex = markupStream.getCurrentIndex();
        try {
            while (markupStream.isCurrentIndexInsideTheStream()) {
                markupStream.next();
                if (markupStream.skipUntil(ComponentTag.class)) {
                    ComponentTag tag = markupStream.getTag();
                    if ((tag != null) && (tag.isOpen() || tag.isOpenClose())) {
                        String tagId = tag.getId();
                        if (fullChildId.equals(tagId)) {
                            ComponentTag fullComponentTag = new ComponentTag(tag);
                            fullComponentTag.setId(childId.toString());
                            controller = ComponentResolvers.resolve(enclosureParent, markupStream, fullComponentTag, new ResolverFilter() {

                                @Override
                                public boolean ignoreResolver(final IComponentResolver resolver) {
                                    return resolver instanceof EnclosureHandler;
                                }
                            });
                            break;
                        } else if (fullChildId.startsWith(tagId + PATH_SEPARATOR)) {
                            fullChildId = Strings.afterFirst(fullChildId, PATH_SEPARATOR);
                        }
                    }
                }
            }
        } finally {
            markupStream.setCurrentIndex(orgIndex);
        }
    }
    checkChildComponent(controller);
    return controller;
}
Also used : EnclosureHandler(org.apache.wicket.markup.parser.filter.EnclosureHandler) ComponentTag(org.apache.wicket.markup.ComponentTag) ResolverFilter(org.apache.wicket.markup.resolver.ComponentResolvers.ResolverFilter) Component(org.apache.wicket.Component) IComponentResolver(org.apache.wicket.markup.resolver.IComponentResolver)

Aggregations

Component (org.apache.wicket.Component)1 ComponentTag (org.apache.wicket.markup.ComponentTag)1 EnclosureHandler (org.apache.wicket.markup.parser.filter.EnclosureHandler)1 ResolverFilter (org.apache.wicket.markup.resolver.ComponentResolvers.ResolverFilter)1 IComponentResolver (org.apache.wicket.markup.resolver.IComponentResolver)1