Package org.apache.tiles

Examples of org.apache.tiles.ComponentContext


    public void doFilter(ServletRequest request, ServletResponse response,
                         FilterChain chain)
        throws IOException, ServletException {

        TilesContainer container = TilesAccess.getContainer(servletContext);
        ComponentContext ctx = container.getComponentContext(request, response);

        ComponentAttribute attr = new ComponentAttribute();
        attr.setType(ComponentAttribute.TEMPLATE);
        attr.setName(targetAttributeName);
        attr.setValue(getTargetResource(request));
        ctx.putAttribute(targetAttributeName, attr);

        try {
            container.render(request, response, definition);
        } catch (TilesException e) {
            throw new ServletException("Error wrapping jsp with tile definition.", e);
View Full Code Here


        TilesRequestContext tilesContext = getRequestContext(context);
        endContext(tilesContext);
    }
   
    private ComponentContext startContext(TilesRequestContext tilesContext) {
        ComponentContext context = new BasicComponentContext();
        BasicComponentContext.pushContext(context, tilesContext);
        return context;
    }
View Full Code Here

        TilesRequestContext tilesContext = getRequestContext(pageContext);
        return getComponentContext(tilesContext);
    }

    private ComponentContext getComponentContext(TilesRequestContext tilesContext) {
        ComponentContext context = BasicComponentContext.getContext(tilesContext);
        if (context == null) {
            context = new BasicComponentContext();
            BasicComponentContext.pushContext(context, tilesContext);
        }
        return context;
View Full Code Here

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

        ComponentContext componentContext = BasicComponentContext.getContext(context);

        // TODO: Temporary while preparerInstance gets refactored to throw a more specific exception.
        try {
            preparer.execute(context, componentContext);
        } catch (Exception e) {
View Full Code Here

            LOG.info("Access to definition '" + definitionName +
                "' denied.  User not in role '" + definition.getRole());
            return;
        }

        ComponentContext originalContext = getComponentContext(request);
        BasicComponentContext subContext = new BasicComponentContext(originalContext);
        subContext.addMissing(definition.getAttributes());
        BasicComponentContext.pushContext(subContext, request);

        try {
View Full Code Here

        }
    }

    public void render(PageContext pageContext, ComponentAttribute attr)
        throws TilesException, IOException {
        ComponentContext context = getComponentContext(pageContext);
        TilesRequestContext request = getRequestContext(pageContext);

        String type = calculateType(pageContext, attr);
        if ("string".equalsIgnoreCase(type)) {
            pageContext.getOut().print(attr.getValue());
            return;

        }

        Map<String, ComponentAttribute> attrs = attr.getAttributes();
        if (attrs != null) {
            for (Map.Entry<String, ComponentAttribute> a : attrs.entrySet()) {
                context.putAttribute(a.getKey(), a.getValue());
            }
        }

        if (isDefinition(pageContext, attr)) {
            render(request, attr.getValue().toString());
View Full Code Here

TOP

Related Classes of org.apache.tiles.ComponentContext

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.