The code example in Listing 24-1 uses the getUserRoles( ) method to retrieve the user’s roles and displays the contents of a report element if the user role is Manager. This code can be used, for example, in the onPrepare event of a table element to hide or display the table depending on the user role. The code example also uses the appendToJobStatus( ) method to write messages about the user’s roles to the server job status.
reportContext.getAppContext().get("ServerContext")
.appendToJobStatus("The user has a Manager role\n");