Package org.apache.tapestry.util

Examples of org.apache.tapestry.util.ContentType


     * @param encoding The value of the charset parameter of the content type if it is not already present.
     * @return The content type containing a charset parameter, e.g. text/html;charset=utf-8
     */
    private String generateFullContentType(String contentType, String encoding)
    {
        ContentType contentTypeObject = new ContentType(contentType);
        if (contentTypeObject.getParameter("charset") == null)
            contentTypeObject.setParameter("charset", encoding);
        return contentTypeObject.unparse();
    }
View Full Code Here


        {
            IChartProvider provider = (IChartProvider) component;

            Chart chart = provider.getChart();

            OutputStream output = _response.getOutputStream(new ContentType("image/jpeg"));

            // I've seen a few bits of wierdness (including a JVM crash) inside this code.
            // Hopefully, its a multi-threading problem that can be resolved
            // by synchronizing.
View Full Code Here

       
        // do not squeeze on output either
        Object[] args = cycle.getServiceParameters();
        String strArgs = generateOutputString(args);
        if (strArgs != null) {
          OutputStream output = _response.getOutputStream(new ContentType("text/xml"));
          output.write(strArgs.getBytes("utf-8"));
        }
  }
View Full Code Here

            // provide it, try and guess it by the extension.

            if (contentType == null || contentType.length() == 0)
                contentType = getMimeType(resourcePath);

            OutputStream output = _response.getOutputStream(new ContentType(contentType));

            input = new BufferedInputStream(resourceConnection.getInputStream());

            byte[] buffer = new byte[BUFFER_SIZE];
View Full Code Here

    {
        WebSession session = _request.getSession(true);
        String markup = (String) session
                .getAttribute(PortletConstants.PORTLET_EXCEPTION_MARKUP_ATTRIBUTE);

        PrintWriter writer = _response.getPrintWriter(new ContentType("text/html"));

        PortletURL url = _globals.getRenderResponse().createActionURL();

        writer.println("<span class=\"portlet-msg-error\">An exception has occured.</span>");
        writer.println("<br/>");
View Full Code Here

        PortletWebResponse pwr = new PortletWebResponse(response);

        try
        {
            pwr.getOutputStream(new ContentType("foo/bar"));
            unreachable();
        }
        catch (UnsupportedOperationException ex)
        {
            // Expected.
View Full Code Here

        replayControls();

        ServletWebResponse swr = new ServletWebResponse(response);

        assertSame(stream, swr.getOutputStream(new ContentType("foo/bar")));

        verifyControls();
    }
View Full Code Here

        ServletWebResponse swr = new ServletWebResponse(response);

        try
        {
            swr.getOutputStream(new ContentType("foo/bar"));
            unreachable();
        }
        catch (ApplicationRuntimeException ex)
        {
            assertEquals(
View Full Code Here

        replayControls();

        ServletWebResponse swr = new ServletWebResponse(response);

        assertSame(writer, swr.getPrintWriter(new ContentType("foo/bar")));

        verifyControls();
    }
View Full Code Here

        replayControls();

        ServletWebResponse swr = new ServletWebResponse(response);

        assertSame(writer1, swr.getPrintWriter(new ContentType("foo/bar")));

        verifyControls();

        response.reset();
        response.setContentType("zip/zap");
        response.getWriter();
        setReturnValue(response,writer2);

        replayControls();

        assertSame(writer2, swr.getPrintWriter(new ContentType("zip/zap")));

        verifyControls();
    }
View Full Code Here

TOP

Related Classes of org.apache.tapestry.util.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.