Develop > Presentation layer > Management Center framework > Customize the Management Center user interface > Create a new tool for the Management Center > Define OpenLaszlo classes instantiated in a tool definition class


Define 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 instance. 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. In the Enterprise Explorer view, expand LOBTools > WebContent > WEB-INF > src > lzx.

  3. Create a directory to store the new OpenLaszlo library file. Use 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 the new custom tool.

  4. Create an OpenLaszlo initialization library file with this syntax: 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.

  5. Within the initialization library file:

    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> 
      

  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 the 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" /> 
    

    The URL declared in the wcfInitService class must be prefixed with /cmc/.

  10. Add this new initialization library file to the application.


What to do next

After you complete the work:

  1. 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.

  2. Test the work by viewing them in the Management Center, using this URL: https://hostname:8000/lobtools.

  3. Deploy your files to the production environment.


Related concepts

Management Center user interface


Related tasks

Create a new tool for the Management Center

Define OpenLaszlo classes instantiated in a tool definition class


+

Search Tips   |   Advanced Search