Package org.apache.tiles.request

Examples of org.apache.tiles.request.Request


     * @throws IOException If something goes wrong during rendition.
     */
    @Test
    public void testWrite() throws IOException {
        StringWriter writer = new StringWriter();
        Request requestContext = createMock(Request.class);
        expect(requestContext.getWriter()).andReturn(writer);
        replay(requestContext);
        renderer.render("Result", requestContext);
        writer.close();
        assertEquals("Not written 'Result'", "Result", writer.toString());
        verify(requestContext);
View Full Code Here


     * Tests
     * {@link StringRenderer#isRenderable(String, Request)}.
     */
    @Test
    public void testIsRenderable() {
        Request requestContext = createMock(Request.class);
        replay(requestContext);
        assertTrue(renderer.isRenderable("Result", requestContext));
        verify(requestContext);
    }
View Full Code Here

     * @return The servlet-based request context.
     * @throws NotAServletEnvironmentException If a servlet-based request
     * context could not be found.
     */
    public static ServletRequest getServletRequest(Request request) {
        Request currentRequest = request;
        while (true) {
            if (currentRequest == null) {
                throw new NotAServletEnvironmentException("Last Tiles request context is null");
            }

View Full Code Here

    public boolean isRenderable(String path, Request request) {
        return path != null && getDispatchRequest(request) != null && path.startsWith("/");
    }

    private DispatchRequest getDispatchRequest(Request request) {
        Request result = request;
        while (!(result instanceof DispatchRequest) && result instanceof RequestWrapper) {
            result = ((RequestWrapper) result).getWrappedRequest();
        }
        if (!(result instanceof DispatchRequest)) {
            result = null;
View Full Code Here

     * @param key The name of the attribute to get.
     * @return The Attribute.
     * @since 2.2.0
     */
    public Attribute get(String key) {
        Request velocityRequest = createVelocityRequest(getServletContext(),
                null);
        TilesContainer container = TilesAccess.getCurrentContainer(velocityRequest);
        AttributeContext attributeContext = container
                .getAttributeContext(velocityRequest);
        Attribute attribute = attributeContext.getAttribute(key);
View Full Code Here

        return new AbstractDefaultToStringRenderable(getVelocityContext(),
                null, getResponse(), getRequest()) {

            public boolean render(InternalContextAdapter context, Writer writer)
                    throws IOException {
                Request velocityRequest = createVelocityRequest(
                        getServletContext(), writer);
                TilesContainer container = TilesAccess
                        .getCurrentContainer(velocityRequest);
                container.render(attribute, velocityRequest);
                return true;
View Full Code Here

    public Renderable renderDefinition(final String definitionName) {
        return new AbstractDefaultToStringRenderable(getVelocityContext(),
                null, getResponse(), getRequest()) {

            public boolean render(InternalContextAdapter context, Writer writer) {
                Request velocityRequest = createVelocityRequest(
                        getServletContext(), writer);
                TilesContainer container = TilesAccess
                        .getCurrentContainer(velocityRequest);
                container.render(definitionName, velocityRequest);
                return true;
View Full Code Here

    public Renderable renderAttributeContext() {
        return new AbstractDefaultToStringRenderable(getVelocityContext(),
                null, getResponse(), getRequest()) {

            public boolean render(InternalContextAdapter context, Writer writer) {
                Request velocityRequest = createVelocityRequest(
                        getServletContext(), writer);
                TilesContainer container = TilesAccess
                        .getCurrentContainer(velocityRequest);
                container.renderContext(velocityRequest);
                return true;
View Full Code Here

     *
     * @return The started attribute context, ready to be customized.
     * @since 2.2.0
     */
    public AttributeContext startAttributeContext() {
        Request velocityRequest = createVelocityRequest(
                getServletContext(), null);
        TilesContainer container = TilesAccess
                .getCurrentContainer(velocityRequest);
        return container.startContext(velocityRequest);
    }
View Full Code Here

     *
     * @return The tool itself.
     * @since 2.2.0
     */
    public VelocityStyleTilesTool endAttributeContext() {
        Request velocityRequest = createVelocityRequest(getServletContext(),
                null);
        TilesContainer container = TilesAccess
                .getCurrentContainer(velocityRequest);
        container.endContext(velocityRequest);
        return this;
View Full Code Here

TOP

Related Classes of org.apache.tiles.request.Request

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.