private void addTemplateBindings()

in tapestry-framework/src/org/apache/tapestry/BaseComponentTemplateLoader.java [332:396]


    private void addTemplateBindings(IComponent component, OpenToken token)
    {
        IComponentSpecification spec = component.getSpecification();

        Map attributes = token.getAttributesMap();

        if (attributes != null)
        {
            Iterator i = attributes.entrySet().iterator();

            while (i.hasNext())
            {
                Map.Entry entry = (Map.Entry) i.next();

                String name = (String) entry.getKey();
                TemplateAttribute attribute = (TemplateAttribute) entry.getValue();
                AttributeType type = attribute.getType();

                if (type == AttributeType.OGNL_EXPRESSION)
                {
                    addExpressionBinding(
                            component,
                            spec,
                            name,
                            attribute.getValue(),
                            token.getLocation());
                    continue;
                }

                if (type == AttributeType.LOCALIZATION_KEY)
                {
                    addStringBinding(
                            component,
                            spec,
                            name,
                            attribute.getValue(),
                            token.getLocation());
                    continue;
                }

                if (type == AttributeType.LITERAL)
                    addStaticBinding(
                            component,
                            spec,
                            name,
                            attribute.getValue(),
                            token.getLocation());
            }
        }

        // if the component defines a templateTag parameter and 
        // there is no established binding for that parameter, 
        // add a static binding carrying the template tag  
        if (spec.getParameter(ITemplateSource.TEMPLATE_TAG_PARAMETER_NAME) != null
                && component.getBinding(ITemplateSource.TEMPLATE_TAG_PARAMETER_NAME) == null)
        {
            addStaticBinding(
                    component,
                    spec,
                    ITemplateSource.TEMPLATE_TAG_PARAMETER_NAME,
                    token.getTag(),
                    token.getLocation());
        }

    }