Package org.apache.tiles

Examples of org.apache.tiles.AttributeContext


     */
    @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);
        expect(container.evaluate(attribute, pageContext)).andReturn(null);
        expect(attributeContext.getCascadedAttributeNames()).andReturn(null);
        Set<String> names = new HashSet<String>();
        names.add("attributeName");
        expect(attributeContext.getLocalAttributeNames()).andReturn(names);

        replay(pageContext, container, attributeContext);
        ImportAttributeTag tag = new ImportAttributeTag();
        tag.setPageContext(pageContext);
        tag.setIgnore(true);
View Full Code Here


        ServletContext servletContext = EasyMock
                .createMock(ServletContext.class);
        RequestDispatcher rd = EasyMock.createMock(RequestDispatcher.class);
        TilesRequestContext requestContext = new ServletTilesRequestContext(
                servletContext, request, response);
        AttributeContext attributeContext = EasyMock
                .createMock(AttributeContext.class);

        EasyMock.expect(servletContext.getRequestDispatcher("/my/url.do"))
                .andReturn(rd);
        rd.include(request, response);
View Full Code Here

        }

        attribute = (Attribute) value;

        if (attribute == null) {
            AttributeContext evaluatingContext = container
                    .getAttributeContext(context);
            attribute = evaluatingContext.getAttribute(name);
            if (attribute == null && !ignore) {
                throw new NoSuchAttributeException("Attribute '" + name
                        + "' not found.");
            }
        }
View Full Code Here

    }

    /** {@inheritDoc} */
    public void renderContext(Object... requestItems) {
        TilesRequestContext request = getRequestContext(requestItems);
        AttributeContext attributeContext = getAttributeContext(request);

        if (!isPermitted(request, attributeContext.getRoles())) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Access to current attribute context denied. "
                        + "User not in role '" + attributeContext.getRoles());
            }
            return;
        }

        render(request, attributeContext);
View Full Code Here

     *
     * @param tilesContext The request context to use.
     * @return The current attribute context.
     */
    private AttributeContext getAttributeContext(TilesRequestContext tilesContext) {
        AttributeContext context = getContext(tilesContext);
        if (context == null) {
            context = new BasicAttributeContext();
            pushContext(context, tilesContext);
        }
        return context;
View Full Code Here

     *
     * @param tilesContext The request context to use.
     * @return The newly created attribute context.
     */
    private AttributeContext startContext(TilesRequestContext tilesContext) {
        AttributeContext context = new BasicAttributeContext();
        Stack<AttributeContext>  stack = getContextStack(tilesContext);
        if (!stack.isEmpty()) {
            AttributeContext parent = stack.peek();
            context.inheritCascadedAttributes(parent);
        }
        stack.push(context);
        return context;
    }
View Full Code Here

        if (preparer == null) {
            throw new NoSuchPreparerException("Preparer '" + preparerName + " not found");
        }

        AttributeContext attributeContext = getContext(context);

        preparer.execute(context, attributeContext);
    }
View Full Code Here

                LOG.warn(message);
            }
            throw new NoSuchDefinitionException(definitionName);
        }

        AttributeContext originalContext = getAttributeContext(request);
        BasicAttributeContext subContext = new BasicAttributeContext(originalContext);
        subContext.inherit(definition);

        if (!isPermitted(request, subContext.getRoles())) {
            if (LOG.isDebugEnabled()) {
View Full Code Here

        RequestDispatcher rd = EasyMock.createMock(RequestDispatcher.class);
        TilesApplicationContext applicationContext = new ServletTilesApplicationContext(
                servletContext);
        TilesRequestContext requestContext = new ServletTilesRequestContext(
                applicationContext, request, response);
        AttributeContext attributeContext = EasyMock
                .createMock(AttributeContext.class);

        EasyMock.expect(request.getRequestDispatcher("/my/url.do"))
                .andReturn(rd);
        rd.include(request, response);
View Full Code Here

    }

    /** {@inheritDoc} */
    public void renderContext(Object... requestItems) {
        TilesRequestContext request = getRequestContext(requestItems);
        AttributeContext attributeContext = getAttributeContext(request);

        render(request, attributeContext);
    }
View Full Code Here

TOP

Related Classes of org.apache.tiles.AttributeContext

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.