Purpose

This is called to allow display to the home page, and allows full customization of the Home Page.

Applies To

Home Page screen

Signature

public String ucHomeDisplay (
      SesameSession session)   // the current sesameSession

Notes

This method is only called if the behavior setting named USE_ABBREVIATED_HOME_PAGE is set to NO. It allows HTML to be sent directly to the Home Page and allows up to three report_id’s to be specified. These reports will be rendered on the Home Page. This method also allows dynamic substitution of the report_id’s used to display reports on the Home Page.

public void ucHomeDisplay (
      SesameSession session,   // the current sesameSession
      HashMap reports)

Example

This example demonstrates how the home page is customized based upon role. The behavior setting USE_ABBREVIATED_HOME_PAGE is set to No, and this method ensures that the Client role also is automatically assigned the Approver role if it is not already set in their user profile.

    public String ucHomeDisplay (SesameSession session)  {   // the current sesameSession
     
       // if the user has the Client role, make sure they also have the Approver role
        checkClientApproverRole(session);

        return super.ucHomeDisplay(session);
    }
     /**
     * This method checks whether the current user has the Client user role
     * assigned to their account; if it does, then make sure that the Approver
     * user role is also assigned, and if not assigned then add it to their account.
     */
    private void checkClientApproverRole (SesameSession session) {
        String role = session.getUserRole();

        // check if the user is currently in the Approver role
        if (ROLE__APPROVER.equals(role) ) return;

        String userId = session.getUserId();
        Connection con = null;

        try {
            con = Z.pool.getConnection("checkClientApproverRole");

            // get all roles for current user
            ArrayList roles = SecurityGroupUser.getSecurityGroupUsersIDs(con, userId);

            // check if current user is in the Client role or has the Client role
            if (ROLE__CLIENT.equals(role) || roles.contains(ROLE__CLIENT) ) {
                // check if current user does not have the Approver role assigned
                if (! roles.contains(ROLE__APPROVER) ) {
                    // add Approver role to current user
                    String[] group = new String[] {ROLE__APPROVER};
                    SecurityGroupUser.setSecurityGroupUser(con, group, userId, false);  
                    // false=add new role
                    con.commit();

                    Z.log.writeToLog(Z.log.INFO, "Assigned role " + ROLE__APPROVER 
                                    + " to user " + userId);
                }
            }
        } catch (Exception e) {
            ErrorWriter.write(e, ErrorWriter.LOGERR);
        } finally {
            if (con != null) Z.pool.close(con);
        }
    }