Feature Pack 7 or later

Extending the resource bundle and properties files

In this lesson, you add an extended properties file that contains the text for your new widget. The properties file is a resource bundle that contains translatable text, which displays in Management Center for your widget.

Add the text for your widget within a properties file to ensure that the Management Center properties and list views for your widget display text. Include all of the text for your widget within a properties file with resource keys, instead of hardcoding the text in JSP and JSPF files.

Procedure

  1. Copy the generated resource bundle and properties files into your default workspace directory structure.
    1. In a File Manager, go to the com directory within your new widget project directory.
      For example, if your new widget project is at the top-level in your workspace the filepath to the com directory, can be workspace_dir\NewWidgetProject\LOBTools\src\com.
    2. Copy the mycompany directory.
    3. Go to the workspace_dir\LOBTools\Java Resources\src directory.
    4. Paste your copied mycompany directory within the LOBTools\Java Resources\src directory.
    5. Open WebSphere Commerce Developer. Switch to the Enterprise Explorer view.
    6. Right-click the LOBTools directory within your default workspace directory structure. Click Refresh.
    7. In the LOBTools\Java Resources\src directory, ensure that the com.mycompany.commerce.pagelayout.client.lobtools.properties package exists. Within the package, ensure that the PageLayoutLOB.properties and PageLayoutLOB_en_US.properties files exist.
  2. Define the translatable text for your new widget.
    1. In the Enterprise Explorer view, go to the LOBTools\Java Resources\src directory. Expand the com.mycompany.commerce.pagelayout.client.lobtools.properties package. Open the PageLayoutLOB.properties and PageLayoutLOB_en_US.properties files for editing.
      The following generated code is included within the files:
      # Widget properties view
      widgetNamePrompt=Widget Name
      widgetPropertiesPrompt=Widget Properties
      widgetContentPrompt=Widget Content
      ShoppingCartDetailPageWidgetContent=This widget displays the orders you add into your shopping cart
    2. Define any additional translatable text for your widget by adding code into both files.
    3. Save any changes and close the files.
  3. Copy the generated resource bundle extension into your default workspace directory structure and register your properties files.
    1. In your new project directory, go to the lzx directory.
      For example, the filepath to the lzx directory, can be NewWidgetProject\LOBTools\WebContent\WEB-INF\src\lzx.
    2. Copy the mycompany directory.
    3. Go to the LOBTools\WebContent\WEB-INF\src\lzx directory.
    4. Paste your copied mycompany directory within the LOBTools\WebContent\WEB-INF\src\lzx directory.
    5. In the LOBTools\WebContent\WEB-INF\src\lzx\mycompany\pagelayout directory, open the mycompanyPageLayoutResourceBundle.lzx file to review the source code.
      The following generated code is included within the file:
      <library>
            <class name="mycompanyPageLayoutResourceBundle" extends="wcfResourceBundle" 
             baseName="com.mycompany.commerce.pagelayout.client.lobtools.properties.PageLayoutLOB">
                  <wcfResourceBundleKey name="ShoppingCartDetailPageWidgetContent"/>
            </class>
            <mycompanyPageLayoutResourceBundle id="mycompanyPageLayoutResources"/>
      </library> 
      
      
      The code defines that the resource bundle is an extended resource bundle. The code sets the name for the text properties to register the text within the resource bundle. Management Center uses the resource bundles to identify the text that is translatable. The translatable text must be retrieved from the properties file for the language that a user is working within.
    6. Close the file.
  4. Update the default Commerce Composer resource bundle library to include your new resource bundle extension.
    1. In your new project directory, go to the directory.
      For example, the filepath to the lzx directory, can be NewWidgetProject\LOBTools\WebContent\WEB-INF\src\lzx\commerce\pagelayout.
    2. Open the PageLayoutExtensionsLibrary.lzx file to view the source code.
    3. Copy the generated code that includes your widget resource bundle.
      For example, the generated code can resemble the following code:
      <library>
        <!-- Include the file to add any custom libraries. -->
        <include href="../../mycompany/pagelayout/mycompanyPageLayoutResourceBundle.lzx"/>
      </library>
    4. Go to the LOBTools\WebContent\WEB-INF\src\lzx\commerce\pagelayout directory within your default workspace directory structure.
    5. Open the PageLayoutExtensionsLibrary.lzx file for editing.
    6. Paste your copied code within the PageLayoutExtensionsLibrary.lzx file.
    7. Save and close the file.