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
- Open WebSphere Commerce Developer and switch to the Enterprise Explorer view.
- In the Enterprise Explorer view, expand LOBTools > WebContent > WEB-INF > src > lzx.
- 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.
- 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.
- Within the initialization library file:
- 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.
- 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>
- Create a new folder to store the JSP files for your company under the LOBTools/WebContent/jsp directory.
- 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>
- Save the new JSP file in the folder that you created under the LOBTools/WebContent/jsp directory.
- 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/.
- Add this new initialization library file to the application.
What to do next
After you complete the work:
- 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.
- Test the work by viewing them in the Management Center, using this URL: https://hostname:8000/lobtools.
- 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