Java Code Examples for org.springframework.ui.jasperreports.JasperReportsUtils#render()

The following examples show how to use org.springframework.ui.jasperreports.JasperReportsUtils#render() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractJasperReportsSingleFormatView.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * We need to write text to the response Writer.
 * @param exporter the JasperReports exporter to use
 * @param populatedReport the populated {@code JasperPrint} to render
 * @param response the HTTP response the report should be rendered to
 * @throws Exception if rendering failed
 */
protected void renderReportUsingWriter(net.sf.jasperreports.engine.JRExporter exporter,
		JasperPrint populatedReport, HttpServletResponse response) throws Exception {

	// Copy the encoding configured for the report into the response.
	String contentType = getContentType();
	String encoding = (String) exporter.getParameter(net.sf.jasperreports.engine.JRExporterParameter.CHARACTER_ENCODING);
	if (encoding != null) {
		// Only apply encoding if content type is specified but does not contain charset clause already.
		if (contentType != null && !contentType.toLowerCase().contains(WebUtils.CONTENT_TYPE_CHARSET_PREFIX)) {
			contentType = contentType + WebUtils.CONTENT_TYPE_CHARSET_PREFIX + encoding;
		}
	}
	response.setContentType(contentType);

	// Render report into HttpServletResponse's Writer.
	JasperReportsUtils.render(exporter, populatedReport, response.getWriter());
}
 
Example 2
Source File: AbstractJasperReportsSingleFormatView.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * We need to write text to the response Writer.
 * @param exporter the JasperReports exporter to use
 * @param populatedReport the populated {@code JasperPrint} to render
 * @param response the HTTP response the report should be rendered to
 * @throws Exception if rendering failed
 */
protected void renderReportUsingWriter(net.sf.jasperreports.engine.JRExporter exporter,
		JasperPrint populatedReport, HttpServletResponse response) throws Exception {

	// Copy the encoding configured for the report into the response.
	String contentType = getContentType();
	String encoding = (String) exporter.getParameter(net.sf.jasperreports.engine.JRExporterParameter.CHARACTER_ENCODING);
	if (encoding != null) {
		// Only apply encoding if content type is specified but does not contain charset clause already.
		if (contentType != null && !contentType.toLowerCase().contains(WebUtils.CONTENT_TYPE_CHARSET_PREFIX)) {
			contentType = contentType + WebUtils.CONTENT_TYPE_CHARSET_PREFIX + encoding;
		}
	}
	response.setContentType(contentType);

	// Render report into HttpServletResponse's Writer.
	JasperReportsUtils.render(exporter, populatedReport, response.getWriter());
}
 
Example 3
Source File: AbstractJasperReportsSingleFormatView.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * We need to write binary output to the response OutputStream.
 * @param exporter the JasperReports exporter to use
 * @param populatedReport the populated {@code JasperPrint} to render
 * @param response the HTTP response the report should be rendered to
 * @throws Exception if rendering failed
 */
protected void renderReportUsingOutputStream(net.sf.jasperreports.engine.JRExporter exporter,
		JasperPrint populatedReport, HttpServletResponse response) throws Exception {

	// IE workaround: write into byte array first.
	ByteArrayOutputStream baos = createTemporaryOutputStream();
	JasperReportsUtils.render(exporter, populatedReport, baos);
	writeToResponse(response, baos);
}
 
Example 4
Source File: AbstractJasperReportsSingleFormatView.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * We need to write binary output to the response OutputStream.
 * @param exporter the JasperReports exporter to use
 * @param populatedReport the populated {@code JasperPrint} to render
 * @param response the HTTP response the report should be rendered to
 * @throws Exception if rendering failed
 */
protected void renderReportUsingOutputStream(net.sf.jasperreports.engine.JRExporter exporter,
		JasperPrint populatedReport, HttpServletResponse response) throws Exception {

	// IE workaround: write into byte array first.
	ByteArrayOutputStream baos = createTemporaryOutputStream();
	JasperReportsUtils.render(exporter, populatedReport, baos);
	writeToResponse(response, baos);
}