Jump to content
Changes to the Jaspersoft community edition download ×
  • How To Set Role-Based Home Page For Version 5.5


    rmiller

    Introduction

    An article was written in 2009 for version 3.x on this subject and was updated for version 4.x in 2011. With the release of version 5.5 the home page was completely changed, so the previous solution no longer works.

    Role-based login directs the users to a specific home page depending on their role in an organization.

    Solution

    Open WEB-INF/jsp/home/home.jsp and modify it according to the following example.

    The logic of the jsp will display the first page configured for the user.

    This means that if a user has 2 roles that are configured to have a custom page he'll not face issues caused by the double include.

    <%@ page contentType="text/html" %>
    
    <%@ taglib uri="/spring" prefix="spring"%>
    <%@ taglib uri="http://www.springframework.org/security/tags" prefix="authz"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    
    <%-- Default Home page --%>
    <c:set  var="homePageRequested">homeForNonDemo.jsp</c:set>
    
    <authz:authorize ifAllGranted="ROLE_DEMO">
        <%--
            We have special home page for demo user only on PostgreSQL db.
            For other DB's it have same home page as other users.
        --%>
        <c:if test="${demoHomeResourceExists}">
            <c:set  var="homePageRequested">homeForDemo.jsp</c:set>
        </c:if>
    </authz:authorize>
    <authz:authorize ifAllGranted="ROLE_DASHBOARD">
        <c:set  var="homePageRequested">homeForDashboard.jsp</c:set>
    </authz:authorize>
    
    <authz:authorize ifAllGranted="ROLE_HPC_ADMIN">  
        <c:set  var="homePageRequested">homeForHpcAdmin.jsp</c:set>   
    </authz:authorize>
    
    <jsp:include page="${homePageRequested}"/>
    
    

    User Feedback

    Recommended Comments

    There are no comments to display.



    Guest
    This is now closed for further comments

×
×
  • Create New...