Package org.apache.tiles

Examples of org.apache.tiles.Attribute


     * </p>
     *
     * @param nestedTag the put tag desciendent.
     */
    public void processNestedTag(PutAttributeTag nestedTag) {
        Attribute attribute = new Attribute(
            nestedTag.getValue(), nestedTag.getRole(),
            AttributeType.getType(nestedTag.getType()));

        attributeContext.putAttribute(
            nestedTag.getName(),
View Full Code Here


    /** {@inheritDoc} */
    public void execute(TilesRequestContext tilesContext, AttributeContext attributeContext)
    throws PreparerException {
        attributeContext.putAttribute(
            "body",
            new Attribute("This is the value added by the ViewPreparer"));
    }
View Full Code Here

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

                Attribute attr = attributeContext.getAttribute(name);

                if ((attr == null || attr.getValue() == null) && !ignore) {
                    throw new JspException("Error importing attributes. "
                            + "Attribute '" + name + "' has a null value ");
                } else if (attr == null || attr.getValue() == null) {
                    continue;
                }

                pageContext.setAttribute(name, attr.getValue(), scope);
            }
        }
    }
View Full Code Here

     * the appropriate security.
     *
     * @param nestedTag the put tag desciendent.
     */
    public void processNestedTag(AddAttributeTag nestedTag) {
        Attribute attribute = new Attribute(
            nestedTag.getValue(), nestedTag.getRole(),
            AttributeType.getType(nestedTag.getType()));

        this.addValue(attribute);
    }
View Full Code Here

     * the appropriate security.
     *
     * @param nestedTag the put tag desciendent.
     */
    public void processNestedTag(AddAttributeTag nestedTag) {
        Attribute attribute = new Attribute(
            nestedTag.getValue(), nestedTag.getRole(),
            AttributeType.getType(nestedTag.getType()));

        this.addValue(attribute);
    }
View Full Code Here

    // FIXME This is the same as DefinitionsImpl.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()));
            }
        }

        if (child.getTemplate() == null) {
            child.setTemplate(parent.getTemplate());
View Full Code Here

        Map<String, Definition> defs = new HashMap<String, Definition>();

        Definition def = new Definition();
        def.setName("parent.def1");
        def.setTemplate("/test1.jsp");
        Attribute attr = new Attribute();
        attr.setValue("value1");
        def.putAttribute("attr1", attr);
        attr = new Attribute();
        attr.setValue("tiles.def1");
        // No type set
        def.putAttribute("attr2", attr);
        defs.put(def.getName(), def);
        attr = new Attribute();
        attr.setValue("tiles.def1");
        attr.setType(AttributeType.STRING);
        def.putAttribute("attr3", attr);
        defs.put(def.getName(), def);

        def = new Definition();
        def.setName("tiles.def1");
        def.setTemplate("/test2.jsp");
        defs.put(def.getName(), def);

        def = new Definition();
        def.setName("child.def1");
        def.setExtends("parent.def1");
        attr = new Attribute();
        attr.setValue("New value");
        def.putAttribute("attr1", attr);
        defs.put(def.getName(), def);

        Definitions definitions = new DefinitionsImpl();
        try {
            definitions.addDefinitions(defs);
        } catch (NoSuchDefinitionException e) {
            fail("Test failure: " + e);
        }

        def = definitions.getDefinition("parent.def1");

        assertNotNull("Couldn't get parent.", def);
        assertEquals("Incorrect template value.", "/test1.jsp", def
                .getTemplate());
        assertEquals("Incorrect attr1 value", "value1", def
                .getAttribute("attr1").getValue());

        attr = def.getAttributes().get("attr1");
        assertNotNull("Dependent attribute not found.", attr);
        attr = def.getAttributes().get("attr2");
        assertNotNull("Dependent attribute not found.", attr);
        attr = def.getAttributes().get("attr3");
        assertNotNull("Dependent attribute not found.", attr);
        assertTrue("The attribute 'attr3' should be of type STRING", attr
                .getType() == AttributeType.STRING);

        def = definitions.getDefinition("child.def1");

        assertNotNull("Couldn't get child.",
                definitions.getDefinition("child.def1"));
        assertEquals("Incorrect template value." , "/test1.jsp",
                definitions.getDefinition("child.def1").getTemplate());
        assertEquals("Incorrect attr1 value", "New value", definitions
                .getDefinition("child.def1").getAttribute("attr1").getValue());

        attr = def.getAttributes().get("attr1");
        assertNotNull("Dependent attribute not found.", attr);
        attr = def.getAttributes().get("attr2");
        assertNotNull("Dependent attribute not found.", attr);
        attr = def.getAttributes().get("attr3");
        assertNotNull("Dependent attribute not found.", attr);
        assertTrue("The attribute 'attr3' should be of type STRING", attr
                .getType() == AttributeType.STRING);
    }
View Full Code Here

    public void testLocalizedResolveInheritances() {
        Map<String, Definition> defs = new HashMap<String, Definition>();
        Definition def = new Definition();
        def.setName("parent.def1");
        def.setTemplate("/test1.jsp");
        Attribute attr = new Attribute();
        attr.setValue("value1");
        def.putAttribute("attr1", attr);
        defs.put(def.getName(), def);

        def = new Definition();
        def.setName("child.def1");
        def.setExtends("parent.def1");
        attr = new Attribute();
        attr.setValue("New value");
        def.putAttribute("attr1", attr);
        defs.put(def.getName(), def);

        Map<String, Definition> localDefs = new HashMap<String, Definition>();
        def = new Definition();
        def.setName("child.def1");
        def.setExtends("parent.def1");
        attr = new Attribute();
        attr.setValue("US Value");
        def.putAttribute("attr1", attr);
        localDefs.put(def.getName(), def);

        Definitions definitions = new DefinitionsImpl();
        try {
View Full Code Here

        Map<String, Definition> defs = new HashMap<String, Definition>();

        Definition def = new Definition();
        def.setName("parent.def1");
        def.setTemplate("/test1.jsp");
        Attribute attr = new Attribute();
        attr.setValue("value1");
        def.putAttribute("attr1", attr);
        defs.put(def.getName(), def);

        def = new Definition();
        def.setName("child.def1");
        def.setExtends("parent.def1");
        attr = new Attribute();
        attr.setValue("New value");
        def.putAttribute("attr1", attr);
        defs.put(def.getName(), def);

        Definitions definitions = new DefinitionsImpl();
        try {
View Full Code Here

        Map<String, Definition> defs = new HashMap<String, Definition>();

        Definition def = new Definition();
        def.setName("parent.def1");
        def.setTemplate("/test1.jsp");
        Attribute attr = new Attribute();
        attr.setValue("tiles.def2");
        attr.setType(AttributeType.DEFINITION);
        def.putAttribute("attr1", attr);
        defs.put(def.getName(), def);

        def = new Definition();
        def.setName("parent.notype.def1");
        def.setTemplate("/test1.jsp");
        attr = new Attribute();
        attr.setValue("tiles.def2");
        // Don't set the type
        def.putAttribute("attr1", attr);
        defs.put(def.getName(), def);

        def = new Definition();
        def.setName("tiles.def2");
        defs.put(def.getName(), def);

        Definitions definitions = new DefinitionsImpl();
        try {
            definitions.addDefinitions(defs);
        } catch (NoSuchDefinitionException e) {
            fail("Test failure: " + e);
        }

        defs = new HashMap<String, Definition>(defs);
        def = new Definition();
        def.setName("parent.def2");
        def.setTemplate("/test1.jsp");
        attr = new Attribute();
        attr.setValue("tiles.def3");
        def.putAttribute("attr1", attr);
        defs.put(def.getName(), def);
        def = new Definition();
        def.setName("tiles.def3");
        defs.put(def.getName(), def);
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.