Package org.apache.tiles

Examples of org.apache.tiles.Attribute


        TilesRequestContext request = EasyMock.createMock(TilesRequestContext.class);
        EasyMock.expect(request.isUserInRole("myrole")).andReturn(Boolean.TRUE);
        StringWriter writer = new StringWriter();
        EasyMock.expect(request.getWriter()).andReturn(writer);
        EasyMock.replay(request);
        Attribute attribute = new Attribute((Object) "This is the value", "myrole");
        attribute.setRenderer("string");
        container.render(attribute, request);
        writer.close();
        assertEquals("The attribute should have been rendered",
                "This is the value", writer.toString());
        EasyMock.reset(request);
View Full Code Here


     * Tests
     * {@link DirectAttributeEvaluator#evaluate(Attribute, org.apache.tiles.context.TilesRequestContext)}.
     */
    public void testEvaluate() {
        String expression = "This is an expression";
        Attribute attribute = new Attribute(null, expression, null,
                (String) null);
        Object result = evaluator.evaluate(attribute, null);
        assertEquals("The expression has not been evaluated correctly", result,
                expression);
        expression = "${attributeName}";
        attribute.setExpression(expression);
        result = evaluator.evaluate(attribute, null);
        assertEquals("The expression has not been evaluated correctly", result,
                expression);
    }
View Full Code Here

     * Tests {@link BasicTilesContainer#evaluate(Attribute, Object...)}.
     */
    public void testEvaluate() {
        TilesRequestContext request = EasyMock.createMock(TilesRequestContext.class);
        EasyMock.replay(request);
        Attribute attribute = new Attribute((Object) "This is the value");
        Object value = container.evaluate(attribute, request);
        assertEquals("The attribute has not been evaluated correctly",
                "This is the value", value);
    }
View Full Code Here

     *
     * @param context The page context.
     * @return The computed attribute.
     */
    private Attribute computeAttribute(PageContext context) {
        Attribute attribute = (Attribute) value;

        if (attribute == null) {
            AttributeContext evaluatingContext = container
                    .getAttributeContext(context);
            attribute = evaluatingContext.getAttribute(name);
View Full Code Here

     * Computes the default attribute.
     *
     * @return The default attribute.
     */
    private Attribute computeDefaultAttribute() {
        Attribute attribute = null;
        if (defaultValue != null) {
            if (defaultValue instanceof Attribute) {
                attribute = (Attribute) defaultValue;
            } else if (defaultValue instanceof String) {
                attribute = new Attribute(defaultValue,
                        null, defaultValueRole, defaultValueType);
            }
        }
        return attribute;
    }
View Full Code Here

            definition.setName(attributes.getValue("name"));
            definition.setPreparer(attributes.getValue("preparer"));
            definition.setExtends(attributes.getValue("extends"));

            String template = attributes.getValue("template");
            Attribute attribute = Attribute.createTemplateAttribute(template);
            attribute.setExpression(attributes.getValue("templateExpression"));
            attribute.setRole(attributes.getValue("role"));
            String templateType = attributes.getValue("templateType");
            if (templateType != null) {
                attribute.setRenderer(templateType);
            }
            definition.setTemplateAttribute(attribute);
        }
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.setExpression(attributes.getValue("expression"));
            attribute.setRole(attributes.getValue("role"));
            attribute.setRenderer(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,
                    "true".equals(attributes.getValue("cascade")));
        }
View Full Code Here

                throws Exception {
            Definition definition = (Definition) digester.peek(0);
            if (definition.getName() == null) {
                definition.setName(getNextUniqueDefinitionName(definitions));
            }
            Attribute attribute = (Attribute) digester.peek(1);
            attribute.setValue(definition.getName());
            attribute.setRenderer("definition");
        }
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

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.