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
- Copy the generated resource bundle and properties files
into your default workspace directory structure.
- 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.
- Copy the mycompany directory.
- Go to the workspace_dir\LOBTools\Java
Resources\src directory.
- Paste your copied mycompany directory
within the LOBTools\Java Resources\src directory.
- Open WebSphere Commerce Developer. Switch to the Enterprise
Explorer view.
- Right-click the LOBTools directory
within your default workspace directory structure. Click Refresh.
- 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.
- Define the translatable text for your new widget.
- 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
- Define any additional translatable text for your widget
by adding code into both files.
- Save any changes and close the files.
- Copy the generated resource bundle extension into your
default workspace directory structure and register your properties
files.
- 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.
- Copy the mycompany directory.
- Go to the LOBTools\WebContent\WEB-INF\src\lzx directory.
- Paste your copied mycompany directory
within the LOBTools\WebContent\WEB-INF\src\lzx directory.
- 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.
- Close the file.
- Update the default Commerce Composer resource bundle library
to include your new resource bundle extension.
- 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.
- Open the PageLayoutExtensionsLibrary.lzx file
to view the source code.
- 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>
- Go to the LOBTools\WebContent\WEB-INF\src\lzx\commerce\pagelayout directory
within your default workspace directory structure.
- Open the PageLayoutExtensionsLibrary.lzx file
for editing.
- Paste your copied code within the PageLayoutExtensionsLibrary.lzx file.
- Save and close the file.