Develop > Presentation layer > Management Center framework > Customize the Management Center user interface > Create a new tool for the Management Center > Work with UI text and images
Define properties files and bundle keys for user interface text
Include text on the Management Center user interface, such as in the main work area (list, properties, or calendar views), search, explorer view, menu, message, and help text. Rather than hard-coding user interface text in the OpenLaszlo class files, include all text in resource properties files, and associate the files with resource keys. This way, you maintain the user interface code in one area (the OpenLaszlo file) and the text in another (properties file). This is particularly useful if you have text that will change often, or if you support globalization in the coding (that is, support translating the user interface text to various languages).
Before you begin
Before defining resource bundles, see wcfResourceBundle.To define properties files and bundle keys for user interface text:
Procedure
- Navigate to this directory: WCDE_INSTALL\LOBTools\src\com\your_company_name\Management_Center_component\client\lobtools\properties.
- Create a properties file using any text editor. The file name should have a .properties extension and you should create one for each language, if we will have text in multiple languages (for example myFile_en_US.properties for English text, and myFile_fr_FR.properties for French text).
Within this file, list all the user interface text and associate a unique key for each string of text. For example, to include three tabs (called A, B, and C), on a the properties view for an object, include something similar to this:
keyA=A keyB=B keyC=C
- Create a resource bundle to associate with the keys:
- Open WebSphere Commerce Developer and switch to the Enterprise Explorer view.
- In the Enterprise Explorer view, expand LOBTools > WebContent > WEB-INF > src > lzx > your_company_name > Management_Center_component, where Management_Center_component is the name of the new custom tool.
- Create an OpenLaszlo library file with this syntax: Management_Center_componentResourceBundle.lzx. For example, MyCompanyResourceBundle.
- Within the resource bundle library file, define a class that extends wcfResourceBundle. IBM recommends that the class name follow this naming convention: three-character Management Center component code in lower caseResourceBundle. For example, extMyToolResourceBundle. When you create new OpenLaszlo classes, it is recommended that you prefix the class names with ext so that they are clearly identified as extensions.
Specify the resource bundle base name and define an instance of wcfResourceBundleKey for every key in the properties file. For example:
<class name="extMyResourceBundle" extends="wcfResourceBundle" baseName="com.mycompany.catalog.client.lobtools.properties.MyResources"> <wcfResourceBundleKey name="keyA"/> <wcfResourceBundleKey name="keyB"/> <wcfResourceBundleKey name="keyC"/> </class>
Instantiate the resource bundle class and specify a unique identifier that can be used to refer to the resource bundle. For example:
<extMyResourceBundle id="myResources"/>Where:
- extMyResourceBundle
- The name of the resource bundle class.
- myResources
- The id used to reference the resource class in the object definition. For example, displayName="${myResources. ... }".
- Update the Management Center tool definitions to use the resource bundle keys. The following example demonstrates the declaration of an object definitions display name that retrieves the text from a resource bundle:
<class name="extMyObjectDefinition" extends="wcfPrimaryObjectDefinition" displayName="${myResources.keyA.string}"> ... </class>
What to do next
After you complete the work:
- Right-click LOBTools Project; then click Build OpenLaszlo Project to produce an updated ManagementCenter.swf file under the WCDE_INSTALL\workspace\LOBTools\WebContent directory. This is the default environment setting.
- Test the work by viewing them in the Management Center, using this URL: https://hostname:8000/lobtools.
- Deploy your files to the production environment.
Related concepts
Management Center user interface
Related tasks
Create a new tool for the Management Center