Package org.apache.tiles

Examples of org.apache.tiles.AttributeContext


        popContext(request);
    }

    /** {@inheritDoc} */
    public void renderContext(Request request) {
        AttributeContext attributeContext = getAttributeContext(request);

        render(request, attributeContext);
    }
View Full Code Here


        this.context = context;
    }

    /** {@inheritDoc} */
    public AttributeContext getAttributeContext(Request request) {
        AttributeContext context = getContext(request);
        if (context == null) {
            context = new BasicAttributeContext();
            pushContext(context, request);
        }
        return context;
View Full Code Here

     * @param definition The definition to render.
     * @param request The request context.
     * @since 2.1.3
     */
    public void render(Definition definition, Request request) {
        AttributeContext originalContext = getAttributeContext(request);
        BasicAttributeContext subContext = new BasicAttributeContext(originalContext);
        subContext.inherit(definition);

        pushContext(subContext, request);

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

        listAttribute.setInherit(inherit);
        composeStack.push(listAttribute);
        modelBody.evaluateWithoutWriting();
        TilesContainer container = TilesAccess.getCurrentContainer(request);
        listAttribute = (ListAttribute) composeStack.pop();
        AttributeContext attributeContext = null;
        if (!composeStack.isEmpty()) {
            Object obj = composeStack.peek();
            if (obj instanceof Definition) {
                attributeContext = (AttributeContext) obj;
            }
        }
        if (attributeContext == null) {
            attributeContext = container.getAttributeContext(request);
        }
        attributeContext.putAttribute(name, listAttribute, cascade);
    }
View Full Code Here

     * @throws IOException If something goes wrong.
     */
    @Test
    public void testExecute() throws IOException {
        DispatchRequest requestContext = createMock(DispatchRequest.class);
        AttributeContext attributeContext = createMock(AttributeContext.class);

        requestContext.include("/my/url.do");
        replay(requestContext, attributeContext);
        preparer.execute(requestContext, attributeContext);
        verify(requestContext, attributeContext);
View Full Code Here

     * @throws IOException If something goes wrong.
     */
    @Test(expected = PreparerException.class)
    public void testExecuteException() throws IOException {
        DispatchRequest requestContext = createMock(DispatchRequest.class);
        AttributeContext attributeContext = createMock(AttributeContext.class);

        requestContext.include("/my/url.do");
        expectLastCall().andThrow(new IOException());

        replay(requestContext, attributeContext);
View Full Code Here

     * Test method for {@link org.apache.tiles.velocity.template.VelocityStyleTilesTool#get(java.lang.String)}.
     */
    @Test
    public void testGetAttribute() {
        TilesContainer container = createMock(TilesContainer.class);
        AttributeContext attributeContext = createMock(AttributeContext.class);
        ApplicationContext applicationContext = createMock(ApplicationContext.class);
        Attribute attribute = new Attribute("myValue");
        Map<String, Object> requestScope = new HashMap<String, Object>();
        Map<String, Object> applicationScope = new HashMap<String, Object>();
        requestScope.put(TilesAccess.CURRENT_CONTAINER_ATTRIBUTE_NAME, container);

        expect(request.getAttribute(TilesAccess.CURRENT_CONTAINER_ATTRIBUTE_NAME)).andReturn(container);
        expect(applicationContext.getApplicationScope()).andReturn(applicationScope).anyTimes();
        expect(servletContext.getAttribute(ApplicationAccess
                .APPLICATION_CONTEXT_ATTRIBUTE)).andReturn(applicationContext)
                .anyTimes();
        expect(container.getAttributeContext(isA(VelocityRequest.class)))
                .andReturn(attributeContext);
        expect(attributeContext.getAttribute("myAttribute")).andReturn(attribute);

        replay(velocityContext, request, response, servletContext, container,
                attributeContext, applicationContext);
        initializeTool();
        assertEquals(attribute, tool.get("myAttribute"));
View Full Code Here

     * Test method for {@link org.apache.tiles.velocity.template.VelocityStyleTilesTool#startAttributeContext()}.
     */
    @Test
    public void testStartAttributeContext() {
        TilesContainer container = createMock(TilesContainer.class);
        AttributeContext attributeContext = createMock(AttributeContext.class);
        ApplicationContext applicationContext = createMock(ApplicationContext.class);

        Map<String, Object> requestScope = new HashMap<String, Object>();
        Map<String, Object> applicationScope = new HashMap<String, Object>();
        requestScope.put(TilesAccess.CURRENT_CONTAINER_ATTRIBUTE_NAME, container);
View Full Code Here

     * Test method for {@link org.apache.tiles.velocity.template.VelocityStyleTilesTool#endAttributeContext()}.
     */
    @Test
    public void testEndAttributeContext() {
        TilesContainer container = createMock(TilesContainer.class);
        AttributeContext attributeContext = createMock(AttributeContext.class);
        ApplicationContext applicationContext = createMock(ApplicationContext.class);

        Map<String, Object> requestScope = new HashMap<String, Object>();
        Map<String, Object> applicationScope = new HashMap<String, Object>();
        requestScope.put(TilesAccess.CURRENT_CONTAINER_ATTRIBUTE_NAME, container);
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.