Examples of TilesContainer


Examples of org.apache.tiles.TilesContainer

        templateAttribute.setRole(role);
        definition.setTemplateAttribute(templateAttribute);
        definition.setExtends(extend);
        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

    }

    /** {@inheritDoc} */
    // TODO Add a MutableContainer so that this can be done?
    public int doEndTag() {
        TilesContainer container =
            JspUtil.getContainer(pageContext, 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);
        JspUtil.setContainer(pageContext, mutableContainer, containerKey);

        return EVAL_PAGE;
View Full Code Here

Examples of org.apache.tiles.TilesContainer

     * @param context The page context to use.
     * @param key The key under which the container is stored.
     * @since 2.1.0
     */
    public static void setCurrentContainer(PageContext context, String key) {
        TilesContainer container = getContainer(context, key);
        if (container != null) {
            context.setAttribute(ServletUtil.CURRENT_CONTAINER_ATTRIBUTE_NAME,
                    container, PageContext.REQUEST_SCOPE);
        } else {
            throw new NoSuchContainerException("The container with the key '"
View Full Code Here

Examples of org.apache.tiles.TilesContainer

     * @param context The page context to use.
     * @return The current Tiles container to use in web pages.
     * @since 2.1.0
     */
    public static TilesContainer getCurrentContainer(PageContext context) {
        TilesContainer container = (TilesContainer) context.getAttribute(
                ServletUtil.CURRENT_CONTAINER_ATTRIBUTE_NAME,
                PageContext.REQUEST_SCOPE);
        if (container == null) {
            container = getContainer(context);
            context.setAttribute(ServletUtil.CURRENT_CONTAINER_ATTRIBUTE_NAME,
View Full Code Here

Examples of org.apache.tiles.TilesContainer

            }
        }
        session.setAttribute(DefaultLocaleResolver.LOCALE_KEY, locale);
        ServletUtil.setCurrentContainer(request, request
                .getSession().getServletContext(), containerKey);
        TilesContainer container = ServletUtil.getCurrentContainer(request, request
                .getSession().getServletContext());
        container.render("test.localized.definition", request, response);
    }
View Full Code Here

Examples of org.apache.tiles.TilesContainer

            throws PortletException, IOException {
        PortletSession portletSession = request.getPortletSession();
        String definition = (String) portletSession.getAttribute("definition");
        if (definition != null) {
            portletSession.removeAttribute("definition");
            TilesContainer container = PortletUtil.getCurrentContainer(request,
                    getPortletContext());
            if (container.isValidDefinition(definition, request, response,
                    getPortletContext())) {
                container.render(definition, request, response,
                        getPortletContext());
                addBackLink(response);
            } else {
                PortletRequestDispatcher dispatcher = getPortletContext()
                        .getRequestDispatcher(
View Full Code Here

Examples of org.apache.tiles.TilesContainer

        EasyMock.replay(context);

        TilesContainerFactory factory = (TilesContainerFactory) AbstractTilesContainerFactory
                .getTilesContainerFactory(context);
        factory.setDefaultConfiguration(defaults);
        TilesContainer container = factory.createContainer(context);

        assertNotNull(container);
        assertTrue("The container is not an instance of KeyedDefinitionsFactoryTilesContainer",
                container instanceof KeyedDefinitionsFactoryTilesContainer);
        KeyedDefinitionsFactoryTilesContainer keyedContainer =
            (KeyedDefinitionsFactoryTilesContainer) container;
        assertNotNull(keyedContainer.getDefinitionsFactory());
        assertNotNull(keyedContainer.getDefinitionsFactory("one"));
        assertNotNull(keyedContainer.getDefinitionsFactory("two"));
        //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("The container has been initialized, the exception is ok", te);
            }
View Full Code Here

Examples of org.apache.tiles.TilesContainer

    /**
     * Tests {@link BasicTilesContainerFactory#createContainer(TilesApplicationContext)}.
     */
    public void testCreateContainer() {
        TilesContainer container = factory.createContainer(applicationContext);
        assertTrue("The class of the container is not correct",
                container instanceof BasicTilesContainer);
    }
View Full Code Here

Examples of org.apache.tiles.TilesContainer

    /**
     * Tests {@link BasicTilesContainerFactory#createRendererFactory(TilesApplicationContext,
     * TilesContextFactory, TilesContainer, AttributeEvaluator)}.
     */
    public void testCreateRendererFactory() {
        TilesContainer container = factory.createContainer(applicationContext);
        TilesRequestContextFactory requestContextFactory = factory
                .createRequestContextFactory(applicationContext);
        LocaleResolver resolver = factory.createLocaleResolver(applicationContext,
                requestContextFactory);
        AttributeEvaluator evaluator = factory.createEvaluator(applicationContext,
View Full Code Here

Examples of org.apache.tiles.TilesContainer

    /**
     * Tests {@link BasicTilesContainerFactory#createDefaultAttributeRenderer(TilesApplicationContext,
     * TilesContextFactory, TilesContainer, AttributeEvaluator)}.
     */
    public void testCreateDefaultAttributeRenderer() {
        TilesContainer container = factory.createContainer(applicationContext);
        TilesRequestContextFactory requestContextFactory = factory
                .createRequestContextFactory(applicationContext);
        LocaleResolver resolver = factory.createLocaleResolver(applicationContext,
                requestContextFactory);
        AttributeEvaluator evaluator = factory.createEvaluator(applicationContext,
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.