How-to define localized access keys for command components
By Frank Nimphius on Nov 18, 2010
Command components in ADF Faces have a "textAndAccessKey"
property that developers can use to specify access keys, a character that when
pressed in combination with the alt-key invokes the component action.
Similar, input components have a "labelAndAccessKey" property defined to specify an access key that puts the focus onto the component when used. To define an access key, you use "&" within the label or text string, just in front of the character to become the access key character.
For example, "&Ok" defines the access key to be alt+o. "Su&bmit", defines alt+b as the access key for a command button with the text string Submit.
The same notation "&" can be used when the text or label is read from a resource properties file, in which case the entry is
If you created a German translation of this resource file, the key definition may look as shown below
mypage.command. submitKey =&Bestaetigung;
Note the difference however. The "C" in Cancel does not show in "Abbrechen". Therefore the access key will change for the translation. To ensure consistent access keys to be used, the only option developers have is to choose characters as access keys that exist in all translations.
If the internationalized strings and labels are read from a Java resource bundle, then, to define the access key, you use the ampersand "&" character only. The "&" string needs to be used in properties files only, not in Java.