Examples of ListAttribute


Examples of org.apache.tiles.ListAttribute

     * @param inherit If <code>true</code> the list contained in the in the same
     * attribute of the parent definition will be extended.
     * @since 2.2.0
     */
    public void start(ArrayStack<Object> composeStack, String role, boolean inherit) {
        ListAttribute listAttribute = new ListAttribute();
        listAttribute.setRole(role);
        listAttribute.setInherit(inherit);
        composeStack.push(listAttribute);
    }
View Full Code Here

Examples of org.apache.tiles.ListAttribute

     * @param requestItems The request objects.
     * @since 2.2.0
     */
    public void end(TilesContainer container, ArrayStack<Object> composeStack,
            String name, boolean cascade, Object... requestItems) {
        ListAttribute listAttribute = (ListAttribute) composeStack.pop();
        AttributeContext attributeContext = null;
        if (!composeStack.isEmpty()) {
            Object obj = composeStack.peek();
            if (obj instanceof Definition) {
                attributeContext = (AttributeContext) obj;
View Full Code Here

Examples of org.apache.tiles.ListAttribute

     * @since 2.2.0
     */
    private void addAttributeToList(Attribute attribute,
            ArrayStack<Object> composeStack, Object value, String expression,
            String body, String role, String type) {
        ListAttribute listAttribute = (ListAttribute) ComposeStackUtil
                .findAncestorWithClass(composeStack, ListAttribute.class);

        if (listAttribute == null) {
            throw new NullPointerException("There is no ListAttribute in the stack");
        }
        if (value != null) {
            attribute.setValue(value);
        } else if (attribute.getValue() == null && body != null) {
            attribute.setValue(body);
        }
        if (expression != null) {
            attribute.setExpressionObject(Expression
                    .createExpressionFromDescribedExpression(expression));
        }
        if (role != null) {
            attribute.setRole(role);
        }
        if (type != null) {
            attribute.setRenderer(type);
        }
        listAttribute.add(attribute);
    }
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

     */
    @SuppressWarnings("unchecked")
    private static Attribute replaceVarsInListAttribute(ListAttribute listAttr,
            Object... vars) {
        Attribute nuattr;
        ListAttribute nuListAttr = new ListAttribute();
        nuListAttr.setInherit(listAttr.isInherit());
        List<Object> nuItems = (List<Object>) nuListAttr.getValue();
        for (Object item : (List<Object>) listAttr.getValue()) {
            if (item instanceof Attribute) {
                Attribute child = (Attribute) item;
                child = replaceVarsInAttribute(child, vars);
                nuItems.add(child);
View Full Code Here

Examples of org.apache.tiles.ListAttribute

     */
    @SuppressWarnings("unchecked")
    @Test
    public void testReplacePlaceholdersListAttribute() {
        Map<String, Attribute> attributes = new HashMap<String, Attribute>();
        ListAttribute listAttribute = new ListAttribute();
        ListAttribute internalListAttribute = new ListAttribute();
        listAttribute.setInherit(true);
        attributes.put("myList", listAttribute);
        listAttribute.add(new Attribute("value{2}"));
        listAttribute.add(new Attribute("value{2}{3}"));
        listAttribute.add(internalListAttribute);
        internalListAttribute.add(new Attribute("secondvalue{2}"));
        internalListAttribute.add(new Attribute("secondvalue{2}{3}"));
        Definition definition = new Definition("definitionName", new Attribute(
                "template{1}"), attributes);
        Definition nudef = PatternUtil.replacePlaceholders(definition, "nudef",
                "value0", "value1", "value2", "value3");
        assertEquals("nudef", nudef.getName());
        Attribute attribute = nudef.getTemplateAttribute();
        assertEquals("templatevalue1", attribute.getValue());
        ListAttribute nuListAttribute = (ListAttribute) nudef.getAttribute("myList");
        assertTrue(nuListAttribute.isInherit());
        List<Attribute> list = (List<Attribute>) nuListAttribute.getValue();
        assertEquals(LIST_ATTRIBUTE_SIZE, list.size());
        attribute = list.get(0);
        assertEquals("valuevalue2", attribute.getValue());
        attribute = list.get(1);
        assertEquals("valuevalue2value3", attribute.getValue());
        ListAttribute evaluatedListAttribute = (ListAttribute) list.get(2);
        assertFalse(evaluatedListAttribute.isInherit());
        list = (List<Attribute>) evaluatedListAttribute.getValue();
        assertEquals(2, list.size());
        attribute = list.get(0);
        assertEquals("secondvaluevalue2", attribute.getValue());
        attribute = list.get(1);
        assertEquals("secondvaluevalue2value3", attribute.getValue());
View Full Code Here

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

        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();
        // It is right not to resolve inheritance in this DAO.
        assertEquals(1, attributes.size());
    }
View Full Code Here

Examples of org.apache.tiles.ListAttribute

     */
    @SuppressWarnings("unchecked")
    @Test
    public void testEnd() {
        ArrayStack<Object> composeStack = new ArrayStack<Object>();
        ListAttribute listAttribute = new ListAttribute();
        Attribute attribute = new Attribute();
        composeStack.push(listAttribute);
        composeStack.push(attribute);

        model.end(composeStack, "myValue", "myExpression", "myBody", "myRole",
                "myType");
        assertEquals(1, ((List<Attribute>) listAttribute.getValue()).size());
        assertEquals("myValue", attribute.getValue());
        assertEquals("myExpression", attribute.getExpressionObject()
                .getExpression());
        assertEquals("myRole", attribute.getRole());
        assertEquals("myType", attribute.getRenderer());

        composeStack = new ArrayStack<Object>();
        listAttribute = new ListAttribute();
        attribute = new Attribute();
        composeStack.push(listAttribute);
        composeStack.push(attribute);

        model.end(composeStack, null, "myExpression", "myBody", "myRole",
                "myType");
        assertEquals(1, ((List<Attribute>) listAttribute.getValue()).size());
        assertEquals("myBody", attribute.getValue());
        assertEquals("myExpression", attribute.getExpressionObject()
                .getExpression());
        assertEquals("myRole", attribute.getRole());
        assertEquals("myType", attribute.getRenderer());
View Full Code Here

Examples of org.apache.tiles.ListAttribute

     */
    @SuppressWarnings("unchecked")
    @Test
    public void testExecute() {
        ArrayStack<Object> composeStack = new ArrayStack<Object>();
        ListAttribute listAttribute = new ListAttribute();
        Attribute attribute;
        composeStack.push(listAttribute);

        model.execute(composeStack, "myValue", "myExpression", "myBody",
                "myRole", "myType");
        List<Attribute> attributes = (List<Attribute>) listAttribute.getValue();
        assertEquals(1, attributes.size());
        attribute = attributes.iterator().next();
        assertEquals("myValue", attribute.getValue());
        assertEquals("myExpression", attribute.getExpressionObject().getExpression());
        assertEquals("myRole", attribute.getRole());
        assertEquals("myType", attribute.getRenderer());

        composeStack = new ArrayStack<Object>();
        listAttribute = new ListAttribute();
        attribute = new Attribute();
        composeStack.push(listAttribute);
        composeStack.push(attribute);

        model.execute(composeStack, null, "myExpression", "myBody", "myRole",
                "myType");
        attributes = (List<Attribute>) listAttribute.getValue();
        assertEquals(1, attributes.size());
        attribute = attributes.iterator().next();
        assertEquals("myBody", attribute.getValue());
        assertEquals("myExpression", attribute.getExpressionObject()
                .getExpression());
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.