Examples of TilesContainer


Examples of org.apache.tiles.TilesContainer

        EasyMock.expect(context.getInitParameterNames()).andReturn(enumeration.elements()).anyTimes();
        EasyMock.expect(context.getResource("/WEB-INF/tiles.xml")).andReturn(url);
        EasyMock.replay(context);

        TilesContainerFactory factory = TilesContainerFactory.getFactory(context);
        TilesContainer container = factory.createContainer(context);

        assertNotNull(container);
        //now make sure it's initialized
        try {
            container.init(new HashMap<String, String>());
            fail("Container should have already been initialized");
        } catch (IllegalStateException te) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Intercepted an exception, it is OK", te);
            }
View Full Code Here

Examples of org.apache.tiles.TilesContainer

     * Tests the setting of the context.
     *
     * @throws TilesException If something goes wrong.
     */
    public void testSetContext() throws TilesException {
        TilesContainer container = EasyMock.createMock(TilesContainer.class);
        context.setAttribute(TilesAccess.CONTAINER_ATTRIBUTE, container);
        EasyMock.replay(context);
        TilesAccess.setContainer(context, container);
        EasyMock.verify(context);
    }
View Full Code Here

Examples of org.apache.tiles.TilesContainer

     * Tests the getting of the context.
     *
     * @throws TilesException If something goes wrong.
     */
    public void testGetContext() throws TilesException {
        TilesContainer container = EasyMock.createMock(TilesContainer.class);
        EasyMock.expect(context.getAttribute(TilesAccess.CONTAINER_ATTRIBUTE)).andReturn(container);
        EasyMock.replay(context);
        assertEquals(container, TilesAccess.getContainer(context));
        EasyMock.verify(context);
    }
View Full Code Here

Examples of org.apache.tiles.TilesContainer

     *
     * @param context The (application) context to use.
     * @return The required Tiles application context.
     */
    public static TilesApplicationContext getApplicationContext(Object context) {
        TilesContainer container = getContainer(context);
        if (container != null) {
            return container.getApplicationContext();
        }
        return (TilesApplicationContext) getAttribute(context, CONTEXT_ATTRIBUTE);
    }
View Full Code Here

Examples of org.apache.tiles.TilesContainer

     * @return The current Tiles container to use in web pages.
     * @since 2.1.0
     */
    public static TilesContainer getCurrentContainer(ServletRequest request,
            ServletContext context) {
        TilesContainer container = (TilesContainer) request
                .getAttribute(CURRENT_CONTAINER_ATTRIBUTE_NAME);
        if (container == null) {
            container = TilesAccess.getContainer(context);
            request.setAttribute(CURRENT_CONTAINER_ATTRIBUTE_NAME, container);
        }
View Full Code Here

Examples of org.apache.tiles.TilesContainer

     * @param key The key under which the container is stored.
     * @since 2.1.0
     */
    public static void setCurrentContainer(ServletRequest request,
            ServletContext context, String key) {
        TilesContainer container = TilesAccess.getContainer(context, key);
        if (container != null) {
            request.setAttribute(CURRENT_CONTAINER_ATTRIBUTE_NAME, container);
        } else {
            throw new NoSuchContainerException("The container with the key '"
                    + key + "' cannot be found");
View Full Code Here

Examples of org.apache.tiles.TilesContainer

     * @param key The key under which the container is stored.
     * @return The required Tiles application context.
     * @since 2.1.0
     */
    public static TilesApplicationContext getApplicationContext(Object context, String key) {
        TilesContainer container = getContainer(context, key);
        if (container != null) {
            return container.getApplicationContext();
        }
        return (TilesApplicationContext) getAttribute(context, CONTEXT_ATTRIBUTE);
    }
View Full Code Here

Examples of org.apache.tiles.TilesContainer

    }

    /** {@inheritDoc} */
    // TODO Add a MutableContainer so that this can be done?
    public int doEndTag() {
        TilesContainer container =
            TilesAccess.getContainer(pageContext.getServletContext(), containerKey);

        if (container != null) {
            LOG.warn("TilesContainer already instantiated for this context under key '"
                    + containerKey + "'. Ignoring request to define.");
            return SKIP_BODY;
        }

        RuntimeConfiguredContext context =
            new RuntimeConfiguredContext(pageContext.getServletContext());

        if (containerFactory != null) {
            context.setInitParameter(
                AbstractTilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM,
                containerFactory);
        }

        // This is to provide compatibility with Tiles 2.0.x
        context.setInitParameter(
                TilesContainerFactory.CONTAINER_FACTORY_MUTABLE_INIT_PARAM,
                "true");

        for (Map.Entry<String, String> entry : initParameters.entrySet()) {
            context.setInitParameter(entry.getKey(), entry.getValue());
        }

        TilesApplicationContext applicationContext = new ServletTilesApplicationContext(
                context);
        AbstractTilesApplicationContextFactory acFactory = AbstractTilesApplicationContextFactory
                .createFactory(applicationContext);
        applicationContext = acFactory.createApplicationContext(context);

        TilesContainer mutableContainer = AbstractTilesContainerFactory
                .getTilesContainerFactory(applicationContext).createContainer(
                        applicationContext);
        TilesAccess.setContainer(context, mutableContainer, containerKey);

        return EVAL_PAGE;
View Full Code Here

Examples of org.apache.tiles.TilesContainer

        definition.setTemplate(template);
        definition.setExtends(extend);
        definition.setRole(role);
        definition.setPreparer(preparer);

        TilesContainer c = JspUtil.getCurrentContainer(pageContext);

        if (c == null) {
            throw new TilesJspException("TilesContainer not initialized");
        }
        if (!(c instanceof MutableTilesContainer)) {
View Full Code Here

Examples of org.apache.tiles.TilesContainer

     */
    public void contextInitialized(ServletContextEvent event) {
        ServletContext servletContext = event.getServletContext();
        String key = servletContext.getInitParameter(
                CONTAINER_KEY_INIT_PARAMETER);
        TilesContainer container = createContainer(servletContext);
        TilesAccess.setContainer(servletContext, container, key);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.