Defining 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 or definition 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 fileIntroduced in Feature Pack 2 or definition 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 your coding (that is, support translating the user interface text to various languages).

Before you begin

Before defining resource bundles, see wcfResourceBundle.

Procedure

  1. Navigate to this directory: WCDE_installdir\LOBTools\src\com\your_company_name\Management_Center_component\client\lobtools\properties.
  2. 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 you 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
    
  3. Create a resource bundle to associate with the keys:
    1. Open WebSphere Commerce Developer and switch to the Enterprise Explorer view.
    2. 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 your new custom tool.
    3. Create an OpenLaszlo library file with this syntax: Management_Center_componentResourceBundle.lzx. For example, MyCompanyResourceBundle. This file must be added to the apprpriate extensions library file. Examples include, MarketingExtensionsLibrary.lzx and FoundationsExtensionsLibrary.lzx
    4. Within the resource bundle library file, define a class that extends wcfResourceBundle. It is recommended 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 lzx/commerce/foundation/restricted/ResourceBundle.lzx/wcfResourceBundleKey for every key in the properties file. Create in the same path used in step 1. Instantiate the resource bundle class and specify a unique identifier that can be used to refer to the resource bundle. For example:
      <library>
      <class name="extMyResourceBundle" extends="wcfResourceBundle"
        baseName="com.mycompany.catalog.client.lobtools.properties.MyResources">
      
        <wcfResourceBundleKey name="keyA"/> 
        <wcfResourceBundleKey name="keyB"/> 
        <wcfResourceBundleKey name="keyC"/> 
      </class>
      <extMyResourceBundle id="myResources"/> 
      </library>
      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. ... }".
  4. Update your Management Center tool definitions to use the resource bundle keys. The following example demonstrates the declaration of an object definition display name that retrieves the text from a resource bundle:
    WebSphere Commerce Version 7.0.0.0Feature Pack 1
    <class name="extMyObjectDefinition" extends="wcfPrimaryObjectDefinition"
    displayName="${myResources.keyA.string}">
    
    ...
    
    </class>
    Introduced in Feature Pack 2
    <PrimaryObjectDefinition definitionName="MyObjectDefinition"
    	displayName="${myResources.keyA}">
    
    ...
    
    </class>

What to do next

After you complete your work:
  1. Right-click LOBTools Project; then click Build OpenLaszlo Project to produce an updated ManagementCenter.swf file under the WCDE_installdir\workspace\LOBTools\WebContent directory. This setting is the default environment setting.
  2. Test your work by viewing them in the Management Center, using this URL: https://hostname:8000/lobtools.
  3. Deploy your files to your production environment.