Retrieving the value of a display key

Some display keys contain a placeholder argument or parameter, designated by {}. PolicyCenter replaces each of these parameters with actual values at run time. For example, in the display key properties file, you see the following:

Java.Activities.Error.CannotPerformAction = You do not have permission to perform actions on the
        following activities\: {0}.

Thus, at run time, PolicyCenter replaces {0} with the appropriate value, in this case, the name of an activity.

Occasionally, there are display keys that contain multiple arguments. For example:

Java.Admin.User.InvalidGroupAdd = The group {0} cannot be added for the user {1} 
        as they do not belong to the same organization.

Method DisplayKey.get

Use the DisplayKey.get method to return the value of the display key. Use the following syntax:

DisplayKey.get(display_key_name)

For example:

DisplayKey.get("Java.Admin.User.DuplicateRoleError")

returns:

User has duplicate roles

This also works with display keys that require a parameter or parameters. To retrieve the parameter value, use the following syntax.

DisplayKey.get(display_key_name, arg1)

For example, the display key properties file defines the following display key with placeholder {0}:

Java.UserDetail.Delete.IsSupervisorError = Cannot delete user because they are supervisor of the
following groups\: {0}.

Suppose that you have the following display key Gosu code:

DisplayKey.get("Java.UserDetail.Delete.IsSupervisorError", GroupName)

If the variable GroupName is defined as WesternRegion, this display key returns the following:

Cannot delete user because they are supervisor of the following groups: WesternRegion

The same syntax works with multiple arguments, as well:

DisplayKey.get(display_key_name, arg1, arg2, ...)
Note: Make sure to include the following line in any Gosu code that calls the DisplayKey.get method:
uses gw.api.locale.DisplayKey