Package org.apache.tiles

Examples of org.apache.tiles.Attribute


     * {@link AbstractBaseAttributeRenderer#render(Attribute, TilesRequestContext)}.
     *
     * @throws IOException If something goes wrong during rendition.
     */
    public void testRender() throws IOException {
        Attribute attribute = new Attribute();
        StringWriter writer = new StringWriter();
        TilesApplicationContext applicationContext = EasyMock
                .createMock(TilesApplicationContext.class);
        TilesRequestContextFactory contextFactory = EasyMock
                .createMock(TilesRequestContextFactory.class);
View Full Code Here


    @Test(expected = TilesJspException.class)
    public void testTagNullEvaluateException() throws TilesJspException {
        PageContext pageContext = createMock(PageContext.class);
        TilesContainer container = createMock(TilesContainer.class);
        AttributeContext attributeContext = createMock(AttributeContext.class);
        Attribute attribute = new Attribute("myValue");
        expect(pageContext.getAttribute(
                ServletUtil.CURRENT_CONTAINER_ATTRIBUTE_NAME,
                PageContext.REQUEST_SCOPE)).andReturn(container);
        expect(container.getAttributeContext(pageContext)).andReturn(attributeContext);
        expect(attributeContext.getAttribute("attributeName")).andReturn(attribute);
View Full Code Here

    @Test
    public void testTagNullEvaluateIgnoreException() throws TilesJspException {
        PageContext pageContext = createMock(PageContext.class);
        TilesContainer container = createMock(TilesContainer.class);
        AttributeContext attributeContext = createMock(AttributeContext.class);
        Attribute attribute = new Attribute("myValue");
        expect(pageContext.getAttribute(
                ServletUtil.CURRENT_CONTAINER_ATTRIBUTE_NAME,
                PageContext.REQUEST_SCOPE)).andReturn(container);
        expect(container.getAttributeContext(pageContext)).andReturn(attributeContext);
        expect(attributeContext.getAttribute("attributeName")).andReturn(attribute);
View Full Code Here

    @Test(expected = TilesJspException.class)
    public void testTagNullEvaluateAllException() throws TilesJspException {
        PageContext pageContext = createMock(PageContext.class);
        TilesContainer container = createMock(TilesContainer.class);
        AttributeContext attributeContext = createMock(AttributeContext.class);
        Attribute attribute = new Attribute("myValue");
        expect(pageContext.getAttribute(
                ServletUtil.CURRENT_CONTAINER_ATTRIBUTE_NAME,
                PageContext.REQUEST_SCOPE)).andReturn(container);
        expect(container.getAttributeContext(pageContext)).andReturn(attributeContext);
        expect(attributeContext.getAttribute("attributeName")).andReturn(attribute);
View Full Code Here

    @Test
    public void testTagNullEvaluateAllIgnoreException() throws TilesJspException {
        PageContext pageContext = createMock(PageContext.class);
        TilesContainer container = createMock(TilesContainer.class);
        AttributeContext attributeContext = createMock(AttributeContext.class);
        Attribute attribute = new Attribute("myValue");
        expect(pageContext.getAttribute(
                ServletUtil.CURRENT_CONTAINER_ATTRIBUTE_NAME,
                PageContext.REQUEST_SCOPE)).andReturn(container);
        expect(container.getAttributeContext(pageContext)).andReturn(attributeContext);
        expect(attributeContext.getAttribute("attributeName")).andReturn(attribute);
View Full Code Here

     */
    class DefaultMutator implements AttributeContextMutator {

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

            this.definition = definition;
        }

        /** {@inheritDoc} */
        public Object mapRow(ResultSet rs, int row) throws SQLException {
            Attribute attribute = new Attribute();
            attribute.setRenderer(rs.getString("TYPE"));
            attribute.setValue(rs.getString("VALUE"));
            definition.putAttribute(rs.getString("NAME"), attribute, rs
                    .getBoolean("CASCADE_ATTRIBUTE"));
            return attribute;
        }
View Full Code Here

     */
    private void validate(Definition definition) {
        Set<String> names = definition.getLocalAttributeNames();
        if (names != null) {
            for (String name : names) {
                Attribute attribute = definition.getLocalAttribute(name);
                if (attribute.getValue() == null) {
                    throw new IllegalArgumentException(
                            "Attribute '" + name + "' value not defined");
                }
            }
        }
        names = definition.getCascadedAttributeNames();
        if (names != null) {
            for (String name : names) {
                Attribute attribute = definition.getCascadedAttribute(name);
                if (attribute.getValue() == null) {
                    throw new IllegalArgumentException(
                            "Attribute '" + name + "' value not defined");
                }
            }
        }
View Full Code Here

            this.definition = definition;
        }

        /** {@inheritDoc} */
        public Object mapRow(ResultSet rs, int row) throws SQLException {
            Attribute attribute = new Attribute();
            attribute.setRenderer(rs.getString("TYPE"));
            attribute.setValue(rs.getString("VALUE"));
            definition.putAttribute(rs.getString("NAME"), attribute, rs
                    .getBoolean("CASCADE_ATTRIBUTE"));
            return attribute;
        }
View Full Code Here

    /**
     * Tests
     * {@link ELAttributeEvaluator#evaluate(Attribute, TilesRequestContext)}.
     */
    public void testEvaluate() {
        Attribute attribute = new Attribute();
        attribute.setValue("${requestScope.object1}");
        assertEquals("The value is not correct", "value", evaluator.evaluate(
                attribute, request));
        attribute.setValue("${sessionScope.object2}");
        assertEquals("The value is not correct", new Integer(1), evaluator
                .evaluate(attribute, request));
        attribute.setValue("${applicationScope.object3}");
        assertEquals("The value is not correct", new Float(2.0), evaluator
                .evaluate(attribute, request));
        attribute.setValue("${object1}");
        assertEquals("The value is not correct", "value", evaluator.evaluate(
                attribute, request));
        attribute.setValue("${object2}");
        assertEquals("The value is not correct", new Integer(1), evaluator
                .evaluate(attribute, request));
        attribute.setValue("${object3}");
        assertEquals("The value is not correct", new Float(2.0), evaluator
                .evaluate(attribute, request));
        attribute.setValue("String literal");
        assertEquals("The value is not correct", "String literal", evaluator
                .evaluate(attribute, request));
        attribute.setValue(new Integer(2));
        assertEquals("The value is not correct", new Integer(2), evaluator
                .evaluate(attribute, request));
    }
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.