JavaScript event handler example
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.
Listing 24-1  
userRoles = reportContext.getAppContext().get("ServerContext").getUserRoles();
 
reportContext.getAppContext().get("ServerContext").appendToJobStatus("The user roles are:" + userRoles +"\n");
 
if (userRoles != null)
{
for (i = 0; i < userRoles.size(); i++)
{
if ( userRoles.get(i) == "Manager")
{
  reportContext.setGlobalVariable("HideDetails", "false");
  reportContext.getAppContext().get("ServerContext")
.appendToJobStatus("The user has a Manager role\n");  
  break;
}
}
}

Additional Links:

Copyright Actuate Corporation 2012