How to Set Role-Based JasperReports Server Home Pages
Introduction
This tutorial shows how to specify a dashboard as a user's home page. The dashboard is visible immediately after logging in to JasperReports Server, and provides a role-based "information cockpit" that helps users make better and faster business decisions.
Product Versions
This tutorial is written for JasperReports Server version 4.0 and later, and requires only slight edits to work in v3.x.
User: Developer
Objectives
This guide will show you how to:
- Create a test role and a test user
- Identify a Dashboard URI
- Edit and assign privileges to a role-based home page
Pre-Requisites
- The SuperMart sample data must be installed to follow this tutorial
-
You need a basic understanding of JasperReports Server, how to create dashboards, and role-based authorization
- For additional details, please refer to the JasperReports Server Pro User Guide located in the jasperreports-server-4.x\docs folder
- To specify a dashboard as a role's home page, you need write permission to the JasperReports Server web application folder
- A basic understanding of JSP and HTML iFrames is helpful, but not required
Creating a Test Role and User
For this tutorial, you will create a test role and user, and grant the test user read privileges to the SuperMart demo folder.
| Step | Action |
| 1 |
Create a new role.
Result: The new role is added in the Roles section |
| 2 |
Grant ROLE_TEST read access to the SuperMart samples.
|
| 3 |
Create a new Test User.
Result: Your new Test User appears in the Users section. |
| 4 |
Associate Test User with ROLE_TEST:
|
Identifying the Dashboard URI
The following steps assure that target users (in this case, Test User) can access the dashboard.
Note: The dashboard URI will be different for superuser than for organization users, including jasperadmin, because superuser has root access to the repository. Superuser's URI path to any resource includes the top-level root/organizations directories.
To make sure the URI you select is accessible by the target users, you need to first emulate the target user.
| Step | Action |
| 1 |
Notice your login id in the upper-right corner: jasperadmin user as Test User. |
| 2 |
Open the dashboard you want to include on the new home page:
Result: The dashboard opens |
| 3 |
Copy the URL from the web browser address bar to a text editor. Example: _http://localhost:8081/jasperserver-pro/flow.html?_flowId=dashboardRuntimeFlow&dashboardResource=/supermart/SupermartDashboard30 |
| 4 |
|
| 5 | In JasperReports Server, click the Log Out link at the upper right to return to jasperadmin view. |
Editing a Role-Based Home Page
A role-based home page requires you to reference the dashboard in a JSP file. You then assign this new homeFor<Role>.jsp file to the role you created earlier. You need a text editor and write access to the application server to complete this step.
| Step | Action |
| 1 |
Copy the file homeForDemo.jsp and rename it homeForTest.jsp. |
| 2 |
src="${pageContext.request.contextPath}/flow.html?_flowId= Save the file to the jsp/ modules/ home directory. You now have a new home page available! |
| 3 |
Assign the new home page to a role:
<authz:authorize ifAllGranted="ROLE_DEMO">
<authz:authorize ifAllGranted="ROLE_TEST|organization_1">
<authz:authorize ifNotGranted="ROLE_DEMO"> |
| 4 |
Save the file, and you are done! Log in as your target user and the dashboard should appear the user’s home page. |
What's Next?
For further details on individual and customized dashboards please refer to:
Written by
This tutorial was written by Kerstin Klein, Professional Services Consultant; and Mary Flynn, Sales Engineer Manager; in June 2009. It was updated for v4.1 by Curtis Stallins with direction from Matt Geise in June 2011.
Language