Examples of ListAttribute


Examples of org.apache.tiles.ListAttribute

        definitionDao.setReader(new DigesterDefinitionsReader());
        EasyMock.replay(applicationContext);
       
        Definition definition = definitionDao.getDefinition(
                "test.inherit.list", Locale.ITALIAN);
        ListAttribute listAttribute = (ListAttribute) definition
                .getAttribute("list");
        List<Attribute> attributes = (List<Attribute>) listAttribute.getValue();
        assertEquals(2, attributes.size());
    }
View Full Code Here

Examples of org.apache.tiles.ListAttribute

                .isCascade());
    }

    /** {@inheritDoc} */
    public void processNestedTag(PutListAttributeTag nestedTag) {
        ListAttribute attribute = new ListAttribute(nestedTag.getAttributes());
        attribute.setRole(nestedTag.getRole());
        attribute.setInherit(nestedTag.getInherit());

        attributeContext.putAttribute(nestedTag.getName(), attribute, nestedTag
                .isCascade());
    }
View Full Code Here

Examples of org.apache.tiles.ListAttribute

                def);
        attribute = def.getAttribute("list");
        assertNotNull("Couldn't Find list attribute.", attribute);
        assertTrue("Attribute not of valid type",
                attribute instanceof ListAttribute);
        ListAttribute listAttribute = (ListAttribute) attribute;
        List<Attribute> list = (List<Attribute>) listAttribute.getValue();
        assertEquals("The list is not of correct size", 1, list.size());
        attribute = list.get(0);
        assertNotNull("Couldn't Find element attribute.", attribute);
        assertEquals("Attribute not of 'definition' type", "definition",
                attribute.getRenderer());
        assertNotNull("Attribute value null", attribute.getValue());
        defName = attribute.getValue().toString();
        def = definitions.get(defName);
        assertNotNull("Couldn't find " + defName + " tile.", def);

        defName = "test.inherit.list.base";
        def = definitions.get(defName);
        assertNotNull("Couldn't find " + defName + " tile.", def);
        defName = "test.inherit.list";
        def = definitions.get(defName);
        assertNotNull("Couldn't find " + defName + " tile.", def);
        listAttribute = (ListAttribute) def.getAttribute("list");
        assertEquals("This definition does not inherit its list attribute",
                true, listAttribute.isInherit());
        defName = "test.noinherit.list";
        def = definitions.get(defName);
        listAttribute = (ListAttribute) def.getAttribute("list");
        assertEquals("This definition inherits its list attribute",
                false, listAttribute.isInherit());
    }
View Full Code Here

Examples of org.apache.tiles.ListAttribute

                .isCascade());
    }

    /** {@inheritDoc} */
    public void processNestedTag(PutListAttributeTag nestedTag) {
        ListAttribute attribute = new ListAttribute(nestedTag.getAttributes());
        attribute.setRole(nestedTag.getRole());
        attribute.setInherit(nestedTag.getInherit());
        definition.putAttribute(nestedTag.getName(), attribute, nestedTag
                .isCascade());
    }
View Full Code Here

Examples of org.apache.tiles.ListAttribute

                .isCascade());
    }

    /** {@inheritDoc} */
    public void processNestedTag(PutListAttributeTag nestedTag) {
        ListAttribute attribute = new ListAttribute(nestedTag.getAttributes());
        attribute.setRole(nestedTag.getRole());
        attribute.setInherit(nestedTag.getInherit());

        attributeContext.putAttribute(nestedTag.getName(), attribute, nestedTag
                .isCascade());
    }
View Full Code Here

Examples of org.apache.tiles.ListAttribute

                def);
        attribute = def.getAttribute("list");
        assertNotNull("Couldn't Find list attribute.", attribute);
        assertTrue("Attribute not of valid type",
                attribute instanceof ListAttribute);
        ListAttribute listAttribute = (ListAttribute) attribute;
        List<Attribute> list = (List<Attribute>) listAttribute.getValue();
        assertEquals("The list is not of correct size", 1, list.size());
        attribute = list.get(0);
        assertNotNull("Couldn't Find element attribute.", attribute);
        assertEquals("Attribute not of 'definition' type", "definition",
                attribute.getRenderer());
        assertNotNull("Attribute value null", attribute.getValue());
        defName = attribute.getValue().toString();
        def = definitions.get(defName);
        assertNotNull("Couldn't find " + defName + " tile.", def);

        defName = "test.inherit.list.base";
        def = definitions.get(defName);
        assertNotNull("Couldn't find " + defName + " tile.", def);
        defName = "test.inherit.list";
        def = definitions.get(defName);
        assertNotNull("Couldn't find " + defName + " tile.", def);
        listAttribute = (ListAttribute) def.getAttribute("list");
        assertEquals("This definition does not inherit its list attribute",
                true, listAttribute.isInherit());
        defName = "test.noinherit.list";
        def = definitions.get(defName);
        listAttribute = (ListAttribute) def.getAttribute("list");
        assertEquals("This definition inherits its list attribute",
                false, listAttribute.isInherit());

        defName = "test.new.attributes";
        def = definitions.get(defName);
        assertNotNull("Couldn't find " + defName + " tile.", def);
        Attribute templateAttribute = def.getTemplateAttribute();
View Full Code Here

Examples of org.apache.tiles.ListAttribute

        Map<String, Definition> name2defs = reader.read(source);
        source.close();
        Definition root = name2defs.get("root");
        Attribute attribute = root.getAttribute("body");
        Definition child = name2defs.get((String) attribute.getValue());
        ListAttribute listAttribute = (ListAttribute) child.getAttribute("list");
        List<Object> list = (List<Object>) listAttribute.getValue();
        assertEquals(((Attribute) list.get(0)).getValue(), "This is a value");
    }
View Full Code Here

Examples of org.apache.tiles.ListAttribute

     * @param modelBody The body.
     * @throws IOException If the body cannot be evaluated.
     */
    public void execute(String role, Request request, ModelBody modelBody) throws IOException {
        Deque<Object> composeStack = ComposeStackUtil.getComposeStack(request);
        ListAttribute listAttribute = new ListAttribute();
        listAttribute.setRole(role);
        composeStack.push(listAttribute);
        modelBody.evaluateWithoutWriting();
        listAttribute = (ListAttribute) composeStack.pop();
        ListAttribute parent = (ListAttribute) composeStack.peek();
        parent.add(listAttribute);
    }
View Full Code Here

Examples of org.apache.tiles.ListAttribute

        Matcher matcher =  OPTIONS_PATTERN.matcher((String) path);

        if (null != matcher && matcher.find()) {
            boolean done = false;
            String match = matcher.group(1);
            ListAttribute fallbacks = (ListAttribute) TilesAccess
                    .getCurrentContainer(request)
                    .getAttributeContext(request)
                    .getAttribute(match);

            if(null == fallbacks){
                throw new IllegalStateException("A matching list-attribute name=\"" + match + "\" must be defined.");
            }else if(fallbacks.getValue().isEmpty()){
                throw new IllegalStateException("list-attribute name=\"" + match + "\" must have minimum one attribute");
            }

            for (Attribute option : (List<Attribute>) fallbacks.getValue()) {
                String template = path.replaceFirst(Pattern.quote(matcher.group()), (String)option.getValue());
                done = renderAttempt(template, request);
                if(done){ break; }
            }
            if (!done) {
View Full Code Here

Examples of org.apache.tiles.ListAttribute

        modelBody.evaluateWithoutWriting();
        requestScope.put(ComposeStackUtil.COMPOSE_STACK_ATTRIBUTE_NAME, composeStack);
        expect(request.getContext("request")).andReturn(requestScope);

        replay(request, modelBody);
        ListAttribute parent = new ListAttribute();
        composeStack.push(parent);
        model.execute("myRole", request, modelBody);
        assertEquals(1, composeStack.size());
        assertEquals(parent, composeStack.pop());
        assertEquals(1, parent.getValue().size());
        ListAttribute listAttribute = (ListAttribute) parent.getValue().get(0);
        assertEquals("myRole", listAttribute.getRole());
        verify(request, modelBody);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.