Package org.apache.tapestry

Examples of org.apache.tapestry.ContentType


        // seperated, and trying to keep stateless and stateful (i.e., perthread scope) services
        // seperated. So we inform the stateful queue service what it needs to do here ...

        _pageRenderQueue.initializeForPartialPageRender(rootRenderCommand);

        ContentType pageContentType = (ContentType) _request.getAttribute(
                InternalConstants.CONTENT_TYPE_ATTRIBUTE_NAME);
        String charset = pageContentType.getParameter(InternalConstants.CHARSET_CONTENT_TYPE_PARAMETER);

        ContentType contentType = new ContentType("text/javascript");
        contentType.setParameter(InternalConstants.CHARSET_CONTENT_TYPE_PARAMETER, charset);

        MarkupWriter writer = _factory.newMarkupWriter(pageContentType);

        JSONObject reply = new JSONObject();

        // ... and here, the pipeline eventually reaches the PRQ to let it render the root render command.

        _partialMarkupRenderer.renderMarkup(writer, reply);

        PrintWriter pw = _response.getPrintWriter(contentType.toString());

        pw.print(reply);

        pw.flush();
    }
View Full Code Here


    {
        Page page = _cache.get(pageName);
        ComponentResources pageResources = page.getRootElement().getComponentResources();

        String contentTypeString = _locator.findMeta(TapestryConstants.RESPONSE_CONTENT_TYPE, pageResources);
        ContentType contentType = new ContentType(contentTypeString);

        String encoding = contentType.getParameter("charset");

        if (encoding == null) encoding = _locator.findMeta(TapestryConstants.RESPONSE_ENCODING, pageResources);

        _request.setEncoding(encoding);
    }
View Full Code Here

        RequestPageCache cache = mockRequestPageCache();
        PageContentTypeAnalyzer analyzer = mockPageContentTypeAnalyzer();
        Component component = mockComponent();
        String pageName = "foo/bar";
        Page page = mockPage();
        ContentType contentType = new ContentType("zig/zag");
        ComponentResources resources = mockComponentResources();

        train_getComponentResources(component, resources);
        train_getPageName(resources, pageName);
        train_get(cache, pageName, page);
View Full Code Here

    public ContentType findContentType(Page page)
    {
        ComponentResources pageResources = page.getRootComponent().getComponentResources();

        String contentTypeString = _metaDataLocator.findMeta(TapestryConstants.RESPONSE_CONTENT_TYPE, pageResources);
        ContentType contentType = new ContentType(contentTypeString);

        // Make sure thre's always a charset specified.

        String encoding = contentType.getParameter(InternalConstants.CHARSET_CONTENT_TYPE_PARAMETER);

        if (encoding == null)
        {
            encoding = _metaDataLocator
                    .findMeta(TapestryConstants.RESPONSE_ENCODING, pageResources);
            contentType.setParameter(InternalConstants.CHARSET_CONTENT_TYPE_PARAMETER, encoding);
        }

        return contentType;
    }
View Full Code Here

        // If we end up doing a partial render, the page render queue service needs to know the
        // page that will be rendered (for logging purposes, if nothing else).

        _queue.initializeForCompletePage(activePage);

        ContentType contentType = _pageContentTypeAnalyzer.findContentType(activePage);

        _request.setAttribute(InternalConstants.CONTENT_TYPE_ATTRIBUTE_NAME, contentType);

        Page containerPage = _cache.get(parameters.getContainingPageName());
View Full Code Here

    public void renderPageResponse(Page page) throws IOException
    {
        Defense.notNull(page, "page");

        ContentType contentType = _pageContentTypeAnalyzer.findContentType(page);

        // For the moment, the content type is all that's used determine the model for the markup writer.
        // It's something of a can of worms.

        MarkupWriter writer = _markupWriterFactory.newMarkupWriter(contentType);

        _markupRenderer.renderPageMarkup(page, writer);

        PrintWriter pw = _response.getPrintWriter(contentType.toString());

        writer.toMarkup(pw);

        pw.flush();
    }
View Full Code Here

            }
        };

        _resources.triggerEvent("providecompletions", new Object[]{input}, callback);

        ContentType contentType = _responseRenderer.findContentType(this);

        MarkupWriter writer = _factory.newMarkupWriter(contentType);

        generateResponseMarkup(writer, matchesHolder.get());

        return new TextStreamResponse(contentType.getMimeType(), writer.toString());
    }
View Full Code Here

        RequestPageCache cache = mockRequestPageCache();
        PageContentTypeAnalyzer analyzer = mockPageContentTypeAnalyzer();
        Component component = mockComponent();
        String pageName = "foo/bar";
        Page page = mockPage();
        ContentType contentType = new ContentType("zig/zag");
        ComponentResources resources = mockComponentResources();

        train_getComponentResources(component, resources);
        train_getPageName(resources, pageName);
        train_get(cache, pageName, page);
View Full Code Here

    {
        // This is a complex area as we are trying to keep public and private services properly
        // seperated, and trying to keep stateless and stateful (i.e., perthread scope) services
        // seperated. So we inform the stateful queue service what it needs to do here ...

        ContentType pageContentType = (ContentType) _request.getAttribute(
                InternalConstants.CONTENT_TYPE_ATTRIBUTE_NAME);
        String charset = pageContentType.getParameter(InternalConstants.CHARSET_CONTENT_TYPE_PARAMETER);

        ContentType contentType = new ContentType(InternalConstants.JSON_MIME_TYPE);
        contentType.setParameter(InternalConstants.CHARSET_CONTENT_TYPE_PARAMETER, charset);

        MarkupWriter writer = _factory.newMarkupWriter(pageContentType);

        JSONObject reply = new JSONObject();

        // ... and here, the pipeline eventually reaches the PRQ to let it render the root render command.

        _partialMarkupRenderer.renderMarkup(writer, reply);

        PrintWriter pw = _response.getPrintWriter(contentType.toString());

        pw.print(reply);

        pw.flush();
    }
View Full Code Here

        Page page = _cache.get(pageName);
        ComponentResources pageResources = page.getRootElement().getComponentResources();

        String contentTypeString = _locator.findMeta(TapestryConstants.RESPONSE_CONTENT_TYPE, pageResources,
                                                     String.class);
        ContentType contentType = new ContentType(contentTypeString);

        String encoding = contentType.getParameter("charset");

        if (encoding == null)
            encoding = _locator.findMeta(TapestryConstants.RESPONSE_ENCODING, pageResources, String.class);

        _request.setEncoding(encoding);
View Full Code Here

TOP

Related Classes of org.apache.tapestry.ContentType

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.