Package org.apache.tapestry.internal.parser

Examples of org.apache.tapestry.internal.parser.ComponentTemplate


    {
        _loadingElement = loadingElement;
        _loadingComponentModel = loadingElement.getComponentResources().getComponentModel();

        String componentClassName = _loadingComponentModel.getComponentClassName();
        ComponentTemplate template = _templateSource.getTemplate(_loadingComponentModel, _locale);

        // When the template for a component is missing, we pretend it consists of just a RenderBody
        // phase. Missing is not an error ... many component simply do not have a template.

        if (template.isMissing())
        {
            _loadingElement.addToTemplate(newRenderBodyElement());
            return;
        }

        // Pre-allocate ids to avoid later name collisions.

        Logger logger = _loadingComponentModel.getLogger();

        // Don't have a case-insensitive Set, so we'll make due with a Map
        Map<String, Boolean> embeddedIds = newCaseInsensitiveMap();

        for (String id : _loadingComponentModel.getEmbeddedComponentIds())
            embeddedIds.put(id, true);

        _idAllocator.clear();

        for (String id : template.getComponentIds())
        {
            _idAllocator.allocateId(id);
            embeddedIds.remove(id);
        }

        if (!embeddedIds.isEmpty())
            logger.error(ServicesMessages.embeddedComponentsNotInTemplate(
                    embeddedIds.keySet(),
                    componentClassName));

        _addAttributesAsComponentBindings = false;

        // The outermost elements of the template belong in the loading component's template list,
        // not its body list. This shunt allows everyone else to not have to make that decision,
        // they can add to the "body" and (if there isn't an active component), the shunt will
        // add the element to the component's template.

        BodyPageElement shunt = new BodyPageElement()
        {
            public void addToBody(PageElement element)
            {
                _loadingElement.addToTemplate(element);
            }
        };

        _bodyPageElementStack.push(shunt);

        for (TemplateToken token : template.getTokens())
        {
            switch (token.getTokenType())
            {
                case TEXT:
                    text((TextToken) token);
View Full Code Here


            _templateResources.put(key, resource);
        }

        // If we haven't yet parsed the template into the cache, do so now.

        ComponentTemplate result = _templates.get(resource);

        if (result == null)
        {
            result = parseTemplate(resource);
            _templates.put(resource, result);
View Full Code Here

            _templateResources.put(key, resource);
        }

        // If we haven't yet parsed the template into the cache, do so now.

        ComponentTemplate result = _templates.get(resource);

        if (result == null)
        {
            result = parseTemplate(resource);
            _templates.put(resource, result);
View Full Code Here

        ComponentTemplateSource templateSource = mockComponentTemplateSource();
        PageElementFactory elementFactory = mockPageElementFactory();
        ComponentPageElement rootElement = mockComponentPageElement();
        InternalComponentResources resources = mockInternalComponentResources();
        ComponentModel model = mockComponentModel();
        ComponentTemplate template = mockComponentTemplate();
        Logger logger = mockLogger();
        ComponentClassResolver resolver = mockComponentClassResolver();

        train_resolvePageNameToClassName(resolver, LOGICAL_PAGE_NAME, PAGE_CLASS_NAME);
View Full Code Here

        PageElementFactory elementFactory = mockPageElementFactory();
        ComponentPageElement rootElement = mockComponentPageElement();
        InternalComponentResources resources = mockInternalComponentResources();
        ComponentModel model = mockComponentModel();
        ComponentModel childModel = mockComponentModel();
        ComponentTemplate template = mockComponentTemplate();
        Logger logger = mockLogger();
        EmbeddedComponentModel emodel = mockEmbeddedComponentModel();
        ComponentPageElement childElement = mockComponentPageElement();
        InternalComponentResources childResources = mockInternalComponentResources();
        Location l = mockLocation();
        PageElement body = mockPageElement();
        ComponentTemplate childTemplate = mockComponentTemplate();
        ComponentClassResolver resolver = mockComponentClassResolver();

        train_resolvePageNameToClassName(resolver, LOGICAL_PAGE_NAME, PAGE_CLASS_NAME);
        train_newRootComponentElement(elementFactory, PAGE_CLASS_NAME, rootElement);
View Full Code Here

    {
        _loadingElement = loadingElement;
        _loadingComponentModel = loadingElement.getComponentResources().getComponentModel();

        String componentClassName = _loadingComponentModel.getComponentClassName();
        ComponentTemplate template = _templateSource.getTemplate(_loadingComponentModel, _locale);

        // When the template for a component is missing, we pretend it consists of just a RenderBody
        // phase. Missing is not an error ... many component simply do not have a template.

        if (template.isMissing())
        {
            addRenderBodyElement();
            return;
        }

        // Pre-allocate ids to avoid later name collisions.

        Log log = _loadingComponentModel.getLog();

        Set<String> embeddedIds = CollectionFactory.newSet(_loadingComponentModel
                .getEmbeddedComponentIds());

        _idAllocator.clear();

        for (String id : template.getComponentIds())
        {
            _idAllocator.allocateId(id);
            embeddedIds.remove(id);
        }

        if (!embeddedIds.isEmpty())
            log.error(ServicesMessages.embeddedComponentsNotInTemplate(
                    embeddedIds,
                    componentClassName));

        _addAttributesAsComponentBindings = false;

        // The outermost elements of the template belong in the loading component's template list,
        // not its body list. This shunt allows everyone else to not have to make that decision,
        // they can add to the "body" and (if there isn't an active component), the shunt will
        // add the element to the component's template.

        BodyPageElement shunt = new BodyPageElement()
        {
            public void addToBody(PageElement element)
            {
                _loadingElement.addToTemplate(element);
            }
        };

        _bodyPageElementStack.addFirst(shunt);

        for (TemplateToken token : template.getTokens())
        {
            switch (token.getTokenType())
            {
                case TEXT:
                    text((TextToken) token);
View Full Code Here

    {
        _loadingElement = loadingElement;
        _loadingComponentModel = loadingElement.getComponentResources().getComponentModel();

        String componentClassName = _loadingComponentModel.getComponentClassName();
        ComponentTemplate template = _templateSource.getTemplate(_loadingComponentModel, _locale);

        // When the template for a component is missing, we pretend it consists of just a RenderBody
        // phase. Missing is not an error ... many component simply do not have a template.

        if (template.isMissing())
        {
            _loadingElement.addToTemplate(newRenderBodyElement());
            return;
        }

        // Pre-allocate ids to avoid later name collisions.

        Log log = _loadingComponentModel.getLog();

        // Don't have a case-insensitive Set, so we'll make due with a Map
        Map<String, Boolean> embeddedIds = newCaseInsensitiveMap();

        for (String id : _loadingComponentModel.getEmbeddedComponentIds())
            embeddedIds.put(id, true);

        _idAllocator.clear();

        for (String id : template.getComponentIds())
        {
            _idAllocator.allocateId(id);
            embeddedIds.remove(id);
        }

        if (!embeddedIds.isEmpty())
            log.error(ServicesMessages.embeddedComponentsNotInTemplate(
                    embeddedIds.keySet(),
                    componentClassName));

        _addAttributesAsComponentBindings = false;

        // The outermost elements of the template belong in the loading component's template list,
        // not its body list. This shunt allows everyone else to not have to make that decision,
        // they can add to the "body" and (if there isn't an active component), the shunt will
        // add the element to the component's template.

        BodyPageElement shunt = new BodyPageElement()
        {
            public void addToBody(PageElement element)
            {
                _loadingElement.addToTemplate(element);
            }
        };

        _bodyPageElementStack.push(shunt);

        for (TemplateToken token : template.getTokens())
        {
            switch (token.getTokenType())
            {
                case TEXT:
                    text((TextToken) token);
View Full Code Here

            _templateResources.put(key, resource);
        }

        // If we haven't yet parsed the template into the cache, do so now.

        ComponentTemplate result = _templates.get(resource);

        if (result == null)
        {
            result = parseTemplate(resource);
            _templates.put(resource, result);
View Full Code Here

TOP

Related Classes of org.apache.tapestry.internal.parser.ComponentTemplate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.