Package org.apache.tiles

Examples of org.apache.tiles.AttributeContext


     *
     * @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);

        pushContext(subContext, request);
View Full Code Here

    private void renderDefinition(TilesContainer container,
            String definitionName, String template, String templateType,
            String templateExpression, String role, String preparer,
            boolean flush, Request request) throws IOException {
        try {
            AttributeContext attributeContext = container
                    .getAttributeContext(request);
            Attribute templateAttribute = Attribute.createTemplateAttribute(template,
                    templateExpression, templateType, role);
            attributeContext.setPreparer(preparer);
            attributeContext.setTemplateAttribute(templateAttribute);
            container.render(definitionName, request);
            if (flush) {
                request.getWriter().flush();
            }
        } finally {
View Full Code Here

     */
    private Map<String, Object> getImportedAttributes(String name,
            String toName, boolean ignore, Request request) {
        TilesContainer container = TilesAccess.getCurrentContainer(request);
        Map<String, Object> retValue = new HashMap<String, Object>();
        AttributeContext attributeContext = container
                .getAttributeContext(request);
        // Some tags allow for unspecified attributes. This
        // implies that the tag should use all of the attributes.
        if (name != null) {
            importSingleAttribute(container, attributeContext, name, toName,
                    ignore, retValue, request);
        } else {
            importAttributes(attributeContext.getCascadedAttributeNames(),
                    container, attributeContext, retValue, ignore, request);
            importAttributes(attributeContext.getLocalAttributeNames(),
                    container, attributeContext, retValue, ignore, request);
        }
        return retValue;
    }
View Full Code Here

        HttpServletRequest httpServletRequest = createMock(HttpServletRequest.class);
        HttpServletResponse httpServletResponse = createMock(HttpServletResponse.class);
        @SuppressWarnings("unchecked")
        Map<String, Object> applicationScope = createMock(Map.class);
        TilesContainer container = createMock(TilesContainer.class);
        AttributeContext attributeContext = createMock(AttributeContext.class);
        Attribute attribute = createMock(Attribute.class);
        expect(pageContext.getAttribute(
                ApplicationAccess.APPLICATION_CONTEXT_ATTRIBUTE,
                PageContext.APPLICATION_SCOPE)).andReturn(applicationContext);
        expect(applicationContext.getApplicationScope()).andReturn(applicationScope).anyTimes();
        expect(pageContext.getRequest()).andReturn(httpServletRequest);
        expect(pageContext.getResponse()).andReturn(httpServletResponse);
        expect(pageContext.getAttribute(TilesAccess.CURRENT_CONTAINER_ATTRIBUTE_NAME, PageContext.REQUEST_SCOPE)).andReturn(container);
        expect(container.getAttributeContext(isA(JspRequest.class))).andReturn(attributeContext);
        expect(attributeContext.getAttribute("name")).andReturn(attribute);
        expect(container.evaluate(isA(Attribute.class), isA(JspRequest.class))).andReturn(new Integer(1));
        pageContext.setAttribute("id", new Integer(1), PageContext.PAGE_SCOPE);
        replay(jspBody, pageContext, parent,
               applicationContext, httpServletRequest, httpServletResponse,
               applicationScope, container, attributeContext, attribute);
View Full Code Here

     */
    private void renderTemplate(TilesContainer container, String template,
            String templateType, String templateExpression, String role,
            String preparer, boolean flush, Request request) throws IOException {
        try {
            AttributeContext attributeContext = container
                    .getAttributeContext(request);
            Attribute templateAttribute = Attribute.createTemplateAttribute(template,
                    templateExpression, templateType, role);
            attributeContext.setPreparer(preparer);
            attributeContext.setTemplateAttribute(templateAttribute);
            container.renderContext(request);
            if (flush) {
                request.getWriter().flush();
            }
        } finally {
View Full Code Here

    /** {@inheritDoc} */
    public Attribute computeAttribute(TilesContainer container, Attribute attribute,
            String name, String role, boolean ignore,
            Object defaultValue, String defaultValueRole, String defaultValueType, Request request) {
        if (attribute == null) {
            AttributeContext evaluatingContext = container
                    .getAttributeContext(request);
            attribute = evaluatingContext.getAttribute(name);
            if (attribute == null) {
                attribute = computeDefaultAttribute(defaultValue,
                        defaultValueRole, defaultValueType);
                if (attribute == null && !ignore) {
                    throw new NoSuchAttributeException("Attribute '" + name
View Full Code Here

     */
    private AttributeEvaluatorFactory attributeEvaluatorFactory;

    /** {@inheritDoc} */
    public AttributeContext startContext(Request request) {
        AttributeContext context = new BasicAttributeContext();
        Deque<AttributeContext>  stack = getContextStack(request);
        if (!stack.isEmpty()) {
            AttributeContext parent = stack.peek();
            context.inheritCascadedAttributes(parent);
        }
        stack.push(context);
        return context;
    }
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.