Jump to content

Change Default Viewer


SeanDay

Recommended Posts

Hi,

 

I would like to have the option to display each report in only one format (e.g. one report that loads direct to PDF another that loads direct to excel etc..)

 

I think I need to modify the DefaultJasperViewer.jsp file (or maybe create one for excel, one for pdf etc then reference this new file on the customization tab when deploying the report).

 

Can anyone offer some advice on what needs to be changed as so far I have been unsuccesful.

 

Thanks,

 

Sean

Link to comment
Share on other sites

  • Replies 8
  • Created
  • Last Reply

Top Posters In This Topic

  • 4 weeks later...

Finaly I got around to looking into this again and have found the solution. It was pretty simple I just modified the DefaultJasperViewer.jsp file and removed the part that produces export buttons and html report content. I then manually added the pdf button part and called the javascript function to display the PDF using onload on the PDF icon. I expect there is a better method of doing this but it works fine for what I need.

 

Contents of the modified DefaultJapserViewer.jsp file are below:

 

 

Code:

<%--
Copyright (C) 2005 - 2007 JasperSoft Corporation. All rights reserved.
http://www.jaspersoft.com.

Unless you have purchased a commercial license agreement from JasperSoft,
the following license terms apply:

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as published by
the Free Software Foundation.

This program is distributed WITHOUT ANY WARRANTY; and without the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
or write to:

Free Software Foundation, Inc.,
59 Temple Place - Suite 330,
Boston, MA USA 02111-1307
--%>

<%--
Default rendering HTML fragment for a JR report called from the JasperViewerTag.

Expects attributes:
pageIndex: Integer Current page in report
lastPageIndex: Integer Greatest page number in report
page: String URL for surrounding page
exporter: JRHtmlExporter The wrapped JasperPrint
pageIndexParameter: String parameter name in URL for paging
--%>

<%@ taglib prefix="spring" uri="/spring" %>
<%@page import="net.sf.jasperreports.engine.export.*" %>
<%@page import="net.sf.jasperreports.engine.*" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="/WEB-INF/jasperserver.tld" prefix="js" %>
<%@page errorPage="/WEB-INF/jsp/JSErrorPage.jsp" %>

<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td colspan="3">
<table width="100%" cellpadding="0" cellspacing="4" border="0">
<tr>
<c:choose>
<c:when test="${emptyReport}">
<td width="100%" align="left">
</c:when>
<c:otherwise>
<td width="35%" align="left">
</c:otherwise>
</c:choose>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<c:if test="${hasInputControls}">
<td width="1" valign="middle">
<a
<c:choose>
<c:when test="${reportControlsLayout == 2}">
href="javascript:backToInputControlsPage();"
</c:when>
<c:when test="${reportControlsLayout == 1}">
href="javascript:«»showInputControlsDialog();"
</c:when>
</c:choose>
title="<spring:message code="jasper.report.view.hint.report.options"/>">
<img border="0" src="${pageContext.request.contextPath}/images/report_options.gif" alt="<spring:message code="jasper.report.view.hint.report.options"/>"/>
</a>
</td>
<td width="1">
  
<c:if test="${!showClose and !emptyReport}"> </c:if>
</td>
</c:if>
<c:if test="${showClose}">
<td width="1" valign="middle">
<a href="javascript:closeViewReport();" title="<spring:message code="jasper.report.view.hint.close"/>">
<img border="0" src="${pageContext.request.contextPath}/images/return_to_repo.gif" alt="<spring:message code="jasper.report.view.hint.close"/>"/>
</a>
</td>
<td width="1">
  
<c:if test="${!emptyReport}"> </c:if>
</td>
</c:if>
<c:if test="${(showClose || hasInputControls) and !emptyReport}">
<td width="1" style="border-left:1px solid #C0C0C0">  </td>
</c:if>
<c:if test="${!emptyReport}">
<input type="hidden" name="output"/>
<td width="1" valign="middle"><a href="javascript:exportReport('pdf')" title="<spring:message code='jasper.report.view.hint.export.pdf'/>"><img src="${pageContext.request.contextPath}/images/pdf.gif" onload="javascript:exportReport('pdf')" border="0" alt="<spring:message code='jasper.report.view.hint.export.pdf'/>"/></a></td>
<td width="1">  </td>
</c:if>
</tr>
</table>
</td>
</td>
</tr>
<c:choose>
<c:when test="${emptyReport}">
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td nowrap="nowrap" colspan="3" align="center">
<spring:message code="jasper.report.view.empty"/>
</td>
</tr>
</c:when>
</c:choose>
</table>
</td></tr>
</table>
Link to comment
Share on other sites

Hi Sherman,

 

Thanks for the info, we want most of our reports to go direct to PDF (which is why I replaced the default file as it means we don't have to specify the .jsp for all reports). I have renamed the original DefaultJasperViewer.jsp file so we can still use that for any reports where we require multiple output formats. I will probably also create a specific .jsp that goes direct to excel as well.

 

I am very impressed with JasperReports/JasperServer, I have spent weeks looking at Oracle reports/portal for deployment of reports and was not impressed at all. After spending a few hours (including installing/configuring LDAP etc) I found I could do everything I wanted with JasperServer.

 

Thanks,

 

Sean

Link to comment
Share on other sites

  • 1 year later...

 

Hi,

 

I am having a requirement of using custom JRHtmlExporter i.e i am extending JRHtmlExporter in one of my class and when i call the <customExporter>.exportReport() from DefaultJasperViewer.jsp it is throwing

 

 net.sf.jasperreports.engine.JRException: No input source supplied to the exporter.

 

It is expecting JasperPrint as input and it is not set to the custom class.(Looks like JasperPrint is configured to set to only JRHtmlExporter class.)

 

 

Please let me know is there any configuration changes needs to be done to use custom exporters.

 

Regards

Bhuvi



Post Edited by bhuvi at 07/03/2009 16:50
Link to comment
Share on other sites

  • 1 month later...
  • 2 years later...

Hi Sherman when ever I go to specify the JSP I wanted to use as the viewer then it gives me error "The JSP could not be found at the specified location", and JSP exist at this location, please help I'm stuck with it

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...