Package org.apache.tiles

Examples of org.apache.tiles.TilesContainer


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


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

                .anyTimes();
        EasyMock.replay(context);

        AbstractTilesContainerFactory factory = AbstractTilesContainerFactory
                .getTilesContainerFactory(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

        Attribute attribute = new Attribute("my.definition", null, null, "definition");
        TilesApplicationContext applicationContext = EasyMock
                .createMock(TilesApplicationContext.class);
        TilesRequestContextFactory contextFactory = EasyMock
                .createMock(TilesRequestContextFactory.class);
        TilesContainer container = EasyMock.createMock(TilesContainer.class);
        TilesRequestContext requestContext = EasyMock
                .createMock(TilesRequestContext.class);
        Object[] requestObjects = new Object[0];
        EasyMock.expect(requestContext.getRequestObjects()).andReturn(requestObjects);
        EasyMock.expect(contextFactory.createRequestContext(applicationContext))
                .andReturn(requestContext);
        container.render("my.definition");
        EasyMock.replay(applicationContext, contextFactory, requestContext,
                container);
        renderer.setApplicationContext(applicationContext);
        renderer.setRequestContextFactory(contextFactory);
        renderer.setContainer(container);
View Full Code Here

        Attribute attribute = new Attribute("my.definition", null, null, "definition");
        TilesApplicationContext applicationContext = EasyMock
                .createMock(TilesApplicationContext.class);
        TilesRequestContextFactory contextFactory = EasyMock
                .createMock(TilesRequestContextFactory.class);
        TilesContainer container = EasyMock.createMock(TilesContainer.class);
        TilesRequestContext requestContext = EasyMock
                .createMock(TilesRequestContext.class);
        EasyMock.expect(contextFactory.createRequestContext(applicationContext))
                .andReturn(requestContext);
        Object[] requestObjects = new Object[0];
        EasyMock.expect(requestContext.getRequestObjects()).andReturn(requestObjects);
        EasyMock.expect(container.isValidDefinition("my.definition"))
                .andReturn(Boolean.TRUE);
        container.render("my.definition");
        EasyMock.replay(applicationContext, contextFactory, requestContext,
                container);
        renderer.setApplicationContext(applicationContext);
        renderer.setRequestContextFactory(contextFactory);
        renderer.setContainer(container);
View Full Code Here

        Attribute attribute = new Attribute("Result", null, null, "string");
        TilesApplicationContext applicationContext = EasyMock
                .createMock(TilesApplicationContext.class);
        TilesRequestContextFactory contextFactory = EasyMock
                .createMock(TilesRequestContextFactory.class);
        TilesContainer container = EasyMock.createMock(TilesContainer.class);
        TilesRequestContext requestContext = EasyMock
                .createMock(TilesRequestContext.class);
        Object[] requestObjects = new Object[0];
        EasyMock.expect(requestContext.getRequestObjects()).andReturn(requestObjects);
        EasyMock.expect(contextFactory.createRequestContext(applicationContext))
                .andReturn(requestContext);
        EasyMock.expect(container.isValidDefinition("my.definition"))
                .andReturn(Boolean.TRUE);
        EasyMock.expect(requestContext.getWriter()).andReturn(writer);
        EasyMock.replay(applicationContext, contextFactory, requestContext);
        renderer.setApplicationContext(applicationContext);
        renderer.setRequestContextFactory(contextFactory);
View Full Code Here

        Attribute attribute = new Attribute("/myTemplate.jsp", null, null, "template");
        TilesApplicationContext applicationContext = EasyMock
                .createMock(TilesApplicationContext.class);
        TilesRequestContextFactory contextFactory = EasyMock
                .createMock(TilesRequestContextFactory.class);
        TilesContainer container = EasyMock.createMock(TilesContainer.class);
        TilesRequestContext requestContext = EasyMock
                .createMock(TilesRequestContext.class);
        EasyMock.expect(contextFactory.createRequestContext(applicationContext))
                .andReturn(requestContext);
        Object[] requestObjects = new Object[0];
        EasyMock.expect(requestContext.getRequestObjects()).andReturn(requestObjects);
        requestContext.dispatch("/myTemplate.jsp");
        EasyMock.expect(container.isValidDefinition("my.definition"))
                .andReturn(Boolean.TRUE);
        EasyMock.replay(applicationContext, contextFactory, requestContext);
        renderer.setApplicationContext(applicationContext);
        renderer.setRequestContextFactory(contextFactory);
        renderer.setContainer(container);
View Full Code Here

        rendererFactory = new BasicRendererFactory();
        TilesApplicationContext applicationContext = EasyMock
                .createMock(TilesApplicationContext.class);
        TilesRequestContextFactory contextFactory = EasyMock
                .createMock(TilesRequestContextFactory.class);
        TilesContainer container = EasyMock.createMock(TilesContainer.class);
        rendererFactory.setApplicationContext(applicationContext);
        rendererFactory.setRequestContextFactory(contextFactory);
        rendererFactory.setContainer(container);
        EasyMock.replay(applicationContext, contextFactory, container);
    }
View Full Code Here

     * @throws TilesJspException If something goes wrong.
     */
    @Test(expected = TilesJspException.class)
    public void testTagNullEvaluateException() 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);

        replay(pageContext, container, attributeContext);
        ImportAttributeTag tag = new ImportAttributeTag();
        tag.setPageContext(pageContext);
        tag.setName("attributeName");
View Full Code Here

    /**
     * Tests {@link ServletUtil#getContainer(ServletContext)}.
     */
    public void testGetContainer() {
        PageContext context = EasyMock.createMock(PageContext.class);
        TilesContainer container = EasyMock.createMock(TilesContainer.class);
        EasyMock.expect(
                context.getAttribute(TilesAccess.CONTAINER_ATTRIBUTE,
                        PageContext.APPLICATION_SCOPE)).andReturn(container);
        EasyMock.replay(context, container);
        assertEquals(container, JspUtil.getContainer(context));
View Full Code Here

TOP

Related Classes of org.apache.tiles.TilesContainer

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.