How-to define localized access keys for command components

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

mypage.command.submitKey=&Submit;

mypage.command.cancelKey=&Cancel;

If you created a German translation of this resource file, the key definition may look as shown below

mypage.command. submitKey =&Bestaetigung;

mypage.command.cancelKey=&Abbrechen;

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.

Comments:

Post a Comment:
Comments are closed for this entry.
About

The Oracle JDeveloper forum ranks in the Top 5 of the most active forums on the Oracle Technology Network (OTN).



The OTN Harvest blog is a summary of selected topics posted on the OTN Oracle JDeveloper forum.



It is an effort to turn knowledge exchange into an interesting read for developers who enjoy little nuggets of wisdom





Frank Nimphius

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today