Setting the Home Page¶
The home page is the first page a user sees when logging in to JasperReports Server. You can set the home page to a specified flow based on user role.
Setting the Library as the Home Page
The following example shows how to set the library page as the home page of a non-administrative user:
-
Open the file
<js-webapp>\WEB-INF\jasperserver-servlet-pro.xml(commercial editions) orjasperserver-servlet.xml(community edition) for editing. -
Locate the home page bean:
proHomePageByRole(commercial editions)homePageByRole(community edition) -
Locate the line under this bean for
ROLE_USERand modify it to direct to the library page:<bean id="proHomePageByRole" class="java.util.ArrayList"> <constructor-arg> <list> <value>ROLE_ADMINISTRATOR|redirect:/flow.html?_flowId=homeFlow</value> <value>ROLE_USER|redirect:/flow.html?_flowId=searchFlow&mode=library</value> </list> </constructor-arg> </bean>Note
For a user with multiple roles, the
proHomePageByRolebean redirects the user to the page specified by the first matching role on the list. For example, for an administrator with ROLE_ADMINISTRATOR and ROLE_USER roles, theROLE_ADMINSTRATORredirect is applied because it appears first in the bean. When adding your own roles to this bean, insert them in the order that works for you. -
Save the modified file and reload the web app in the app server to see the changes (see 1.0.1, “Reloading the JasperReports Server Web App,” on page 1).
-
Log into JasperReports Server as joeuser. The library page is displayed.
Note
You can use this method for dashboards. For example:
<value>ROLE_ADMINISTRATOR|redirect:/dashboard/viewer.html#/public/Samples/Dashboards/1._Supermart_Dashboard</value>
This method does not work with viewReportFlow.
Setting a report as the home page
The following example shows how to set a report as the home page based on a role. This example uses the 01. Geographic Results by Segment Report.
Note
All roles should start with the prefix 'ROLE_'.
For example:
'ROLE_MANAGER_DIME'
-
First, set up the role and create a sample user:
- Create the role you want to use, for example,
ROLE_REPORT_HOME. - Create a user HomeUser and add
ROLE_REPORT_HOMEto HomeUser.
- Create the role you want to use, for example,
-
Open the file
<js-webapp>\WEB-INF\jsp\modules\home\home.jspin an editor and add the following lines:<authz:authorize access="hasRole('ROLE_REPORT_HOME')"> <c:redirect url="http://localhost:8080/jasperserver-pro-601/flow.html?_flowId=viewReportFlow &standAlone=true&_flowId=viewReportFlow&ParentFolderUri=%2Fpublic%2FSamples%2FReports& reportUnit=%2Fpublic%2FSamples%2FReports%2F01._Geographic_Results_by_Segment_Report"/> </authz:authorize>Note
To find the URI for the report you want to use, open the report in the repository and copy the URI.
-
Save the modified file and restart the application server to see changes.
-
Log into JasperReports Server as HomeUser. The report is displayed.