Package org.apache.tapestry.internal.parser

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


    {
        Log log = newLog();

        replay();

        ComponentTemplate result = parse(log, file);

        verify();

        return result;
    }
View Full Code Here


        Log log = newLog();
        Resource resource = getResource("justHTML.html");

        replay();

        ComponentTemplate template = newParser(log).parseTemplate(resource);

        assertSame(template.getResource(), resource);

        List<TemplateToken> tokens = template.getTokens();

        // They add up quick ...

        assertEquals(tokens.size(), 20);
View Full Code Here

    }

    @Test
    public void instrumented_element()
    {
        ComponentTemplate template = parse("instrumented_element.html");
        List<TemplateToken> tokens = template.getTokens();

        assertEquals(tokens.size(), 3);

        StartComponentToken start = get(tokens, 0);

        assertEquals(start.getId(), "fred");
        assertEquals(start.getType(), "Fred");
        assertEquals(start.getElementName(), "html");

        AttributeToken attr = get(tokens, 1);

        assertEquals(attr.getName(), "param");
        assertEquals(attr.getValue(), "value");

        assertTrue(EndElementToken.class.isInstance(tokens.get(2)));

        assertEquals(template.getComponentIds(), Arrays.asList("fred"));
    }
View Full Code Here

    {
        Log log = newLog();

        replay();

        ComponentTemplate template = parse(log, "component_ids.html");

        Set<String> ids = template.getComponentIds();

        assertEquals(ids, newSet(Arrays.asList("bomb", "border", "zebra")));

        verify();
    }
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();

        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.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

    public void caching()
    {
        Resource baseResource = newResource("Fred.class");

        TemplateParser parser = mockTemplateParser();
        ComponentTemplate template = mockComponentTemplate();
        ComponentModel model = mockComponentModel();

        train_getComponentClassName(model, PACKAGE + ".Fred");

        train_getBaseResource(model, baseResource);
View Full Code Here

        Resource baseResource = new ClasspathResource(loader, "baz/Biff.class");
        Resource localized = baseResource.withExtension(InternalConstants.TEMPLATE_EXTENSION);

        TemplateParser parser = mockTemplateParser();
        ComponentTemplate template = mockComponentTemplate();
        InvalidationListener listener = mockInvalidationListener();

        train_getComponentClassName(model, "baz.Biff");

        train_getBaseResource(model, baseResource);
View Full Code Here

    public void localization_to_same()
    {
        Resource baseResource = newResource("Fred.class");

        TemplateParser parser = mockTemplateParser();
        ComponentTemplate template = mockComponentTemplate();
        ComponentModel model = mockComponentModel();

        train_getComponentClassName(model, PACKAGE + ".Fred");

        train_getBaseResource(model, baseResource);
View Full Code Here

        // Simpler to do it this way ...

        Resource contextTemplateResource = newResource("Fred.tml");

        TemplateParser parser = mockTemplateParser();
        ComponentTemplate template = mockComponentTemplate();
        ComponentModel model = mockComponentModel();
        PageTemplateLocator locator = mockPageTemplateLocator();
        Locale locale = Locale.FRENCH;

        train_getComponentClassName(model, PACKAGE + ".NotInClasspath");
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.