Tutorial: Customizing the Toolbar and Export Report Dialog of the Default BIRT Report Viewer
<p>Hello,</p><p> </p><p>I recently had the task of customizing the default BIRT Report Viewer. My customer wanted to limit the buttons available on the Toolbar and wanted to limit the options available for the "Export Report" dialog. I found some similar topics here in the BIRT Exchange forums (with hints that lead to the information below), but nothing that descriped the procedure outright. I wanted to pull this into a single post, so that someone in the future might find it useful</p><p> </p><p>( note to other devs: This may not be the optimal way of doing things, but it works and I found it safer then trying to delete unneeded emitted *.jar files )</p><p>( note to forum moderators: if this post is in the wrong place, please move to the correct area, thx ).</p><p> </p><p>I am currently using BIRT 4.3.0</p><p> </p><p> </p><p><span class='bbc_underline'><strong>Topic 1: How to Modify the Default BIRT Report Viewer Toolbar</strong></span></p><p> </p><p>You may want your toolbar to look something like this,</p><p> </p><p>[color=#0000ff;].WebContentwebcontentbirtpagescontrol [/color]folder</p><p>2) Open "ToolbarFragment.jsp" in a text editor</p><p>3) Use the [font="'courier new', courier, monospace;"]<% /* Commented Code */ %>[/font] syntax in java server pages to comment out the desired<br />
artifacts, the for the example image above your toolbar section should look like this,</p><p> </p><p>[font="'courier new', courier, monospace;"]<TD COLSPAN='2'><br />
<DIV ID="toolbar"><br />
<TABLE CELLSPACING="1px" CELLPADDING="1px" WIDTH="100%" CLASS="birtviewer_toolbar"><br />
<TR><TD></TD></TR><br />
<TR><br />
<%--<br />
/*<br />
<TD WIDTH="6px"/><br />
<TD WIDTH="15px"><br />
<INPUT TYPE="image" NAME='toc' SRC="birt/images/Toc.gif"<br />
TITLE="<%= BirtResources.getHtmlMessage( "birt.viewer.toolbar.toc" )%>"<br />
ALT="<%= BirtResources.getHtmlMessage( "birt.viewer.toolbar.toc" )%>" CLASS="birtviewer_clickable"><br />
</TD><br />
*/<br />
--%><br />
<TD WIDTH="6px"/><br />
<TD WIDTH="15px"><br />
<INPUT TYPE="image" NAME='parameter' SRC="birt/images/Report_parameters.gif"<br />
TITLE="<%= BirtResources.getHtmlMessage( "birt.viewer.toolbar.parameter" )%>" <br />
ALT="<%= BirtResources.getHtmlMessage( "birt.viewer.toolbar.parameter" )%>" CLASS="birtviewer_clickable"><br />
</TD><br />
<%--<br />
/*<br />
<TD WIDTH="6px"/><br />
<TD WIDTH="15px"><br />
<INPUT TYPE="image" NAME='export' SRC="birt/images/Export.gif"<br />
TITLE="<%= BirtResources.getHtmlMessage( "birt.viewer.toolbar.export" )%>"<br />
ALT="<%= BirtResources.getHtmlMessage( "birt.viewer.toolbar.export" )%>" CLASS="birtviewer_clickable"><br />
</TD><br />
*/<br />
--%><br />
<TD WIDTH="6px"/><br />
<TD WIDTH="15px"><br />
<INPUT TYPE="image" NAME='exportReport' SRC="birt/images/ExportReport.gif"<br />
TITLE="<%= BirtResources.getHtmlMessage( "birt.viewer.toolbar.exportreport" )%>"<br />
ALT="<%= BirtResources.getHtmlMessage( "birt.viewer.toolbar.exportreport" )%>" CLASS="birtviewer_clickable"><br />
</TD><br />
<TD WIDTH="6px"/><br />
<TD WIDTH="15px"><br />
<INPUT TYPE="image" NAME='print' SRC="birt/images/Print.gif"<br />
TITLE="<%= BirtResources.getHtmlMessage( "birt.viewer.toolbar.print" )%>"<br />
ALT="<%= BirtResources.getHtmlMessage( "birt.viewer.toolbar.print" )%>" CLASS="birtviewer_clickable"><br />
</TD><br />
<%<br />
if( ParameterAccessor.isSupportedPrintOnServer )<br />
{<br />
%><br />
<%--<br />
/* <br />
<TD WIDTH="6px"/><br />
<TD WIDTH="15px"><br />
<INPUT TYPE="image" NAME='printServer' SRC="birt/images/PrintServer.gif"<br />
TITLE="<%= BirtResources.getHtmlMessage( "birt.viewer.toolbar.printserver" )%>"<br />
ALT="<%= BirtResources.getHtmlMessage( "birt.viewer.toolbar.printserver" )%>" CLASS="birtviewer_clickable"><br />
</TD><br />
*/<br />
--%><br />
<%<br />
}<br />
%> <br />
<TD ALIGN='right'><br />
</TD><br />
<TD WIDTH="6px"/><br />
</TR><br />
</TABLE><br />
</DIV><br />
</TD>[/font]</p><p> </p><p>[font="arial, helvetica, sans-serif;"]4) Save the File[/font]</p><p> </p><p> </p><p> </p><p><span class='bbc_underline'><strong>Topic 2: How to Modify the Default BIRT Report Viewer Export Report Dialog</strong></span></p><p> </p><p>You may want your default report export dialog to look like this,</p><p> </p><p>[color=#0000cd;].WebContentwebcontentbirtpagesdialog[/color] folder</p><p>2) Open "ExportReportDialogFragment.jsp" in a text editor</p><p>3) At the beginning of the file, Comment out the section about the supported formats and intialize the string array to the following,<br />
<br />
[font="'courier new', courier, monospace;"] <%<br />
/*<br />
String[] supportedFormats = ParameterAccessor.supportedFormats;<br />
*/<br />
String[] supportedFormats = {"pdf","docx","pptx","xlsx"};<br />
%>[/font]</p><p> </p><p>4) Save the File</p><p>5) Now modify how the export formats are displayed (as in the image above), to do so,</p><p> 5a) Go to, [color=#0000cd;].WebContentWEB-INF[/color] folder</p><p> 5b) Open "viewer.properties" in a text editor</p><p> 5c) Modify the output display text section to the following,</p><p> </p><p> [font="'courier new', courier, monospace;"]# [OUTPUT FORMAT LABEL NAME]<br />
#viewer.label.html=HTML<br />
viewer.label.pdf=PDF *.pdf<br />
#viewer.label.postscript=PostScript<br />
#viewer.label.doc=Word<br />
#viewer.label.xls=Excel<br />
#viewer.label.ppt=PowerPoint<br />
#viewer.label.ods=OpenDocument Spreadsheet<br />
#viewer.label.odt=OpenDocument Text<br />
#viewer.label.odp=OpenDocument Presentation<br />
viewer.label.docx=Word *.docx<br />
viewer.label.pptx=PowerPoint *.pptx<br />
viewer.label.xlsx=Excel *.xlsx[/font]</p><p> </p><p> 5d) Save the File</p><p> </p><p>Finished!</p><p> </p><p>Like I said this may not be the optimal way of configuring the BIRT Viewer, but I was unable to find other solutions that did not require deleting emitted *.jar files, which makes me uneasy if I want to add them back later on.</p><p> </p><p> </p><p> </p>