JasperReports Server uses the SiteMesh framework to lay out and decorate nearly every page. The decoration is the HTML for the headers and footers that are nearly identical on every page.
The SiteMesh framework is controlled by the following files:
| • | <js-webapp>/WEB-INF/web.xml |
| • | <js-webapp>/WEB-INF/sitemesh.xml |
| • | <js-webapp>/WEB-INF/decorators.xml |
| • | <js-webapp>/WEB-INF/decorators/main.jsp |
| • | <js-webapp>/WEB-INF/decorators/decorators.jsp |
Essentially, the XML files specify how UI pages should be generated, and the JSP files generate the pages. The following sections describe these files and how to customize the JSPs to change the overall branding that appears in the UI.
web.xml
The <js-webapp>/WEB-INF/web.xml configuration file contains the configuration information that enables SiteMesh. You can see that SiteMesh’s PageFilter class is applied to all targeted URLs (that is, <url-pattern>/*</url-pattern>):
sitemesh.xml and decorators.xml
The SiteMesh page filter assumes that the <js-webapp>/WEB-INF/sitemesh.xml file specifies further configurations. You can see that the main decorator’s definition points to decorators.xml. In addition, you see the SiteMesh mapping that handles the default locale (U. S. English):
Next, look at the <js-webapp>/WEB-INF/decorators.xml file. First, it defines URL patterns that SiteMesh should skip. Then, it defines the main decorator JSP page that is used by JasperReports Server:
main.jsp and decorator.jsp
In <js-webapp>/WEB-INF/decorators/, the main.jsp includes the decorator.jsp file, and together they set the appearance and layout of the JasperReports Server web interface. the figure “JasperReports Server Display Elements” shows the display elements as they appear in JasperReports Server.
JasperReports Server Display Elements |
|
In particular, decorator.jsp specifies all the display elements that appear as the header and footer of every JasperReports Server page. Inside the header and footer and main frame is the <decorator:body/> tag that specifies where to add the HTML content generated for the target page.
In the following listing of decorator.jsp, you can see the structure of every JasperReports Server HTML page, with the main frame, the banner, the body content, and the footer:
For example, if the user clicks View > Reports, the WEB-INF/jsp/modules/ListReports.jsp is executed. The ListReports.jsp generates the HTML content. Before this content is emitted, the SiteMesh page filter inserts the content into the location specified by <decorator:body/>. Then, the whole HTML content is sent to the user’s browser.
Editing decorator.jsp for Rebranding
Now that you know how decorator.jsp defines the main page of the server UI, you can customize the file. If you use JasperReports Server as part of your suite of business applications, you may not want the Jaspersoft branding on the page. Editing the decorators.jsp file in the deployed webapp lets you remove the branding. The following elements make up the Jaspersoft branding:
| • | The page title appearing in the browser. |
| • | The About link and copyright footer on every page. |
To edit the page title:
| 1. | Edit the file <js-webapp>/WEB-INF/decorators/decorator.jsp. |
| 2. | Change the title text, for example: |
| 3. | After saving your changes to the JSP file, restart your application server or reload the JasperReports Server web app. |
To remove the footer text:
| 1. | Edit the file <js-webapp>/WEB-INF/decorators/decorator.jsp. |
| 2. | Change the footer text, for example to comment out the about and copyright lines: |
...<div id="footer" class="footer"><!-- <a id="about" href="#"><spring:message code="decorator.aboutLink"/></a> <p id="copyright"><spring:message code="decorators.main.copyright"/></p>--></div>...[/code] |
| 3. | After saving your changes to the JSP file, restart your application server or reload the JasperReports Server web app. |
Recommended Comments
There are no comments to display.