Defining an initialization service

When you open a tool and select a store, the Management Center framework invokes the initialization services that are defined as part of the wcfBusinessObjectEditor instanceIntroduced in Feature Pack 2 or as part of the definition that extends /wcfBusinessObjectEditor. Initialization services are used to set up the context information that is required by other services included in the tool.

Before you begin

Before defining an initialization service, review the following classes:

Procedure

  1. Open WebSphere Commerce Developer and switch to the Enterprise Explorer view.
  2. Complete one of the following steps:
    • WebSphere Commerce Version 7.0.0.0Feature Pack 1In the Enterprise Explorer view, expand LOBTools > WebContent > WEB-INF > src > lzx.
    • Introduced in Feature Pack 2In the Enterprise Explorer view, expand LOBTools > WebContent > config.
  3. Create a directory to store a new initialization file.
    OptionDescription
    WebSphere Commerce Version 7.0.0.0Feature Pack 1OpenLaszlo library file WebSphere Commerce Version 7.0.0.0Feature Pack 1Use a directory structure similar to the following example: LOBTools/WebContent/WEB-INF/src/lzx/your_company_name/Management_Center_component, where Management_Center_component is the name of your new custom tool.
    Introduced in Feature Pack 2Definition file Introduced in Feature Pack 2Use a directory structure similar to the following example: LOBTools/WebContent/config/your_company_name/Management_Center_component, where Management_Center_component is the name of your new custom tool.
  4. Create your new initialization file:
    OptionDescription
    WebSphere Commerce Version 7.0.0.0Feature Pack 1OpenLaszlo initialization library file WebSphere Commerce Version 7.0.0.0Feature Pack 1Use the following syntax to create this file: Management_Center_componentname in camel caseInitService.lzx. For example, CatalogManagementInitService.lzx. Within this file, the class name must follow this syntax: three-character Management Center component code in lower caseManagement_Center_componentInitService. For example, catCatalogInitService.
    Introduced in Feature Pack 2Initialization definition file Introduced in Feature Pack 2Use the following syntax to create this file: Management_Center_componentname in camel caseInitService.def. For example, CatalogManagementInitService.def. Within this file, the definition name must follow this syntax: three-character Management Center component code in lower caseManagement_Center_componentInitService. For example, catCatalogInitService.
  5. Within the new initialization file:
    OptionDescription
    WebSphere Commerce Version 7.0.0.0Feature Pack 1OpenLaszlo initialization library file WebSphere Commerce Version 7.0.0.0Feature Pack 1
    1. Specify the URL that is invoked by this initialization service and any service parameters to include in the service request. For example:
      <class name="catCatalogInitService" extends="wcfInitService" url="/cmc/GetMasterCatalog"> 
          <wcfServiceParam name="storeId"/> 
      </class> 

      When a new store is selected, this initialization service invokes the /cmc/GetMasterCatalog URL and passes the storeId as a URL parameter.

    2. Instantiate the new class as a child of the wcfBusinessObjectEditor instance:
      <class name="extMyTool" extends="wcfBusinessObjectEditor"> 
      
      ... 
      
      <!—- Add the instantiations for the init service definitions --> 
      <extMyInitService/> 
      
      ... 
      
      </class> 
    Introduced in Feature Pack 2Initialization definition file Introduced in Feature Pack 2
    1. Specify the URL that is invoked by this initialization service and any service parameters to include in the service request. For example:
      <InitService definitionName="catCatalogInitService" url="/cmc/GetMasterCatalog"> 
          <ServiceParam name="storeId"/> 
      </InitService>

      When a new store is selected, this initialization service invokes the /cmc/GetMasterCatalog URL and passes the storeId as a URL parameter.

    2. Add the new definition as a child element of the wcfBusinessObjectEditor definition:
      <BusinessObjectEditor definitionName="extMyTool"> 
      
      ... 
      
      <!—- Add the init service definitions --> 
      <InitService baseDefinitionName="extMyInitService"/> 
      
      ... 
      
      </BusinessObjectEditor>
  6. Create a new folder to store the JSP files for your company under the LOBTools/WebContent/jsp directory.
  7. Create a new JSP file to return the context values using the following XML format:
    <values> 
        <masterCatalogId>10001</masterCatalogId> 
        <masterCatalogIdentifier>Madisons Master Catalog</masterCatalogIdentifier> 
        <masterCatalogStoreId>10001</masterCatalogStoreId> 
    </values> 
  8. Save your new JSP file in the folder that you created under the LOBTools/WebContent/jsp directory.
  9. Add a struts action to the LOBTools/WebContent/WEB-INF/struts-extension.xml file that forwards to the JSP file. The action path must match the URL specified in the declaration of the wcfInitService class. For example:
    <action path="/GetMasterCatalog" forward="/jsp/commerce/catalog/restricted/GetMasterCatalog.jsp" /> 
    Note: The URL declared in the wcfInitService class must be prefixed with /cmc/.
  10. WebSphere Commerce Version 7.0.0.0Feature Pack 1Add this new initialization library file to the application.

What to do next

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