Package org.apache.tiles

Examples of org.apache.tiles.Attribute


     * @return A new instance of an attribute, whose properties have been
     * replaced with variables' values.
     */
    private Attribute replaceVarsInAttribute(Attribute attr,
            Map<Integer, String> vars) {
        Attribute nuattr = new Attribute();

        nuattr.setRole(replace(attr.getRole(), vars));
        nuattr.setRenderer(attr.getRenderer());
        nuattr.setExpression(attr.getExpression());

        Object value = attr.getValue();
        if (value instanceof String) {
            value = replace((String) value, vars);
        }
        nuattr.setValue(value);
        return nuattr;
    }
View Full Code Here


                .getTemplateAttribute(), vars));

        Set<String> localAttributeNames = d.getLocalAttributeNames();
        if (localAttributeNames != null && !localAttributeNames.isEmpty()) {
            for (String attributeName : localAttributeNames) {
                Attribute attr = d.getLocalAttribute(attributeName);
                Attribute nuattr = replaceVarsInAttribute(attr, vars);

                nudef.putAttribute(replace(attributeName, vars), nuattr);
            }
        }
View Full Code Here

                        + "Attribute with null key found.");
            } else if (name == null) {
                continue;
            }

            Attribute attr = attributeContext.getAttribute(name);

            if (attr != null) {
                try {
                    Object attributeValue = container.evaluate(attr, pageContext);
                    if (attributeValue == null) {
View Full Code Here

     */
    class DefaultMutator implements AttributeContextMutator {

        /** {@inheritDoc} */
        public void mutate(AttributeContext ctx, ServletRequest req) {
            Attribute attr = new Attribute();
            attr.setType(AttributeType.TEMPLATE);
            attr.setValue(getRequestBase(req));
            ctx.putAttribute(definitionAttributeName, attr);
        }
View Full Code Here

                    "Tiles Library Documentation", definitions.get(
                            "doc.mainLayout").getAttribute("title").getValue());

            Definition def = definitions.get("doc.role.test");
            assertNotNull("Couldn't find doc.role.test tile.", def);
            Attribute attribute = def.getAttribute("title");
            assertNotNull("Couldn't Find title attribute.", attribute
                    .getValue());
            assertEquals("Role 'myrole' expected", attribute.getRole(),
                    "myrole");

            def = definitions.get("doc.listattribute.test");
            assertNotNull("Couldn't find doc.listattribute.test tile.", def);
            attribute = def.getAttribute("items");
            assertNotNull("Couldn't Find items attribute.", attribute);
            assertTrue("The class of the attribute is not right",
                    attribute instanceof ListAttribute);
            assertTrue("The class of value of the attribute is not right",
                    attribute.getValue() instanceof List);
        } catch (Exception e) {
            fail("Exception reading configuration." + e);
        }
    }
View Full Code Here

     *
     * @param nestedTag The nested <code>PutAttributeTag</code>
     * @throws JspException Never thrown, it's here for API compatibility.
     */
    public void processNestedTag(PutAttributeTag nestedTag) throws JspException {
        Attribute attr = new Attribute(nestedTag.getValue(),
            nestedTag.getRole(), AttributeType.getType(nestedTag.getType()));
        attributes.put(nestedTag.getName(), attr);
    }
View Full Code Here

    // FIXME This is the same as DefinitionManager.overload.
    protected void overload(Definition parent, Definition child) {
        // Iterate on each parent's attribute and add it if not defined in child.
        for (Map.Entry<String, Attribute> entry : parent.getAttributes().entrySet()) {
            if (!child.hasAttributeValue(entry.getKey())) {
                child.putAttribute(entry.getKey(), new Attribute(entry.getValue()));
            }
        }
        // Set template and role if not setted
        if (child.getTemplate() == null) {
            child.setTemplate(parent.getTemplate());
View Full Code Here

        /** {@inheritDoc} */
        @Override
        public void begin(String namespace, String name, Attributes attributes)
                throws Exception {
            Attribute attribute = (Attribute) digester.peek();
            attribute.setValue(attributes.getValue("value"));
            attribute.setRole(attributes.getValue("role"));
            attribute.setType(AttributeType
                    .getType(attributes.getValue("type")));
        }
View Full Code Here

        /** {@inheritDoc} */
        @Override
        public void begin(String namespace, String name, Attributes attributes)
                throws Exception {
            Attribute attribute = (Attribute) digester.peek(0);
            Definition definition = (Definition) digester.peek(1);
            definition.putAttribute(attributes.getValue("name"), attribute);
        }
View Full Code Here

        this.value = null;
    }

    /** {@inheritDoc} */
    protected void render() throws JspException, TilesException, IOException {
        Attribute attr = (Attribute) value;
        if (attr == null && evaluatingContext != null) {
            attr = evaluatingContext.getAttribute(name);
        }
        if (attr == null && ignore) {
            return;
View Full Code Here

TOP

Related Classes of org.apache.tiles.Attribute

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.