Tutorials > Sales Center > Add an editable column to the Order Items table by creating a new widget manager
Extend the request handler on the Sales Center client to read the BOD message
This section is about extending the request handler on the Sales Center client to read the BOD message.
In the previous step, a BOD message with the list of fulfillment centers was created and returned to the client machine. On the Sales Center client, the request handler needs to be extended to receive and handle the response BOD. Because information related to fulfillment centers is stored at the store level, we need to find a request handler implementation that handles the find store service request, which is com.ibm.commerce.telesales.core.impl.request.GetStoreRequest. Refer to the GetStoreRequest API
for information about extending this class.
To extend an existing service request handlerSee Extend an existing service request handler . You need to extend the request handler to read the BOD message for fulfillment centers, extend the implementation class com.ibm.commerce.telesales.core.impl.request.GetStoreRequest to read the BOD from the server, and store the fulfillment data in the newly created model object.
- In the Package Explorer view, navigate to the com.example.commerce.telesales.myNewPracticePlugin > src project.
- Right-click the com.example.commerce.telesales.myNewPracticePlugin package.
- Select New > class.
- In the Name field, enter ExtendedGetStoreRequest.
- Next to the Superclass field, click Browse.
- In the Choose a type field, enter GetStoreRequest and click OK.
- Click Finish.
- Add the following code to the ExtendedGetStoreRequest class.
package com.example.commerce.telesales.myNewPracticePlugin; /** * @author inst1 * * To change the template for this generated type comment go to * Window > Preferences > Java > Code Style > Code Templates */ public class ExtendedGetStoreRequest extends GetStoreRequest { private static final String TAG_FULFILLMENT_CENTERS_LIST = "Fulfillment_Center_List"; //tags to be created in BOD private static final String TAG_FULFILLMENT_CENTER = "Fulfillment_Center"; private static final String TAG_FULFILLMENT_CENTER_ID = "Id"; private static final String TAG_FULFILLMENT_CENTER_DESC = "Desc"; public static final String TAG_FULFILLMENTCENTER = "FFM";//The tag for fulfillment center protected void unmarshallStore(Store newStore, org.w3c.dom.Element storeElement) { super.unmarshallStore(newStore, storeElement); Vector vffmcList = new Vector(); Element ffmc = getChildElement(storeElement, TAG_FULFILLMENT_CENTERS_LIST); if (ffmc != null) { ArrayList ffmcList = getChildElements(ffmc, TAG_FULFILLMENT_CENTER); for (int i = 0; ffmcList != null && i < ffmcList.size(); i++) { String ffmcId = getChildElementValue((Element) ffmcList.get(i), TAG_FULFILLMENT_CENTER_ID).toString(); String ffmcDesc = getChildElementValue( (Element) ffmcList.get(i), TAG_FULFILLMENT_CENTER_DESC) .toString(); //Initialize model object factory to create the new model // object FFMCenter ffmCenter = (FFMCenter) TelesalesModelObjectFactory .createModelObject(TelesalesModelObjectFactory.MODEL_OBJECT_FFM_CENTER); ffmCenter.setFfmCenterId(ffmcId); ffmCenter.setFfmCenterName(ffmcDesc); vffmcList.add(ffmCenter); } newStore.setData(TAG_FULFILLMENTCENTER, vffmcList); } } }
- From the main menu, select Source > Organize Imports to resolve the compilation errors and save the file.
To read the BOD message that is sent from the server, you override the unmarshallStore method in GetStoreRequest to first call the super class method, then unmarshall the Store element to be read by the Sales Center. Next, create a new FFMCenter model object defined from the TelesalesModelObjectFactory and store the fulfillment center information such as IDs and Names into an FFMCenter model object. Refer to Add a model object.
In this tutorial, you are adding an editable column, and you have the model object created for you by the FFMCenter. In the general case, you might have to create the own model object.
- Register the new implementation using the service requests extension point.
- Click the Extensions tab in the com.example.commerce.telesales.myNewPracticePlugin plug-in.
- Click Add.
- From the Extension Points list, select com.ibm.commerce.telesales.core.serviceRequests. This is the extension point for creating a new service request.
- Click Finish.
- In the All Extensions pane, select com.ibm.commerce.telesales.core.serviceRequests > serviceRequest.
- In the Extensions Element Details pane, set the values...
Name Value Id com.example.commerce.telesales.myNewPracticePlugin.request label Request requestHandlerClass com.example.commerce.telesales.myNewPracticePlugin.ExtendedGetStoreRequest commServiceId com.ibm.commerce.telesales.services.TsCommunication
Click the plugin.xml tab and examine the source code for service requests extension:
<extension point="com.ibm.commerce.telesales.core.serviceRequests"> <serviceRequest commServiceId="com.ibm.commerce.telesales.services.TsCommunication" label="Request" requestHandlerClass="com.example.commerce.telesales.myNewPracticePlugin.ExtendedGetStoreRequest" /> </extension>All the default service request definitions can be found in the com.ibm.commerce.telesales.core.impl plug-in.
- Use the system configurator extension point to indicate that the new implementation is to be used instead of the default IBM Sales Center implementation:
- In the Package Explorer view, navigate to com.example.commerce.telesales.NewPracticePlugin > config project, expand the config.ini file.
- In the config.ini file, add the following to indicate that the new implementation is to be used instead of the default IBM Sales Center implementation for the service request that is defined in the plug-in:
com.ibm.commerce.telesales.findStore=com.example.commerce.telesales.myNewPracticePlugin.request
- Save and close the file
So far, the contents in the config.ini should look like this:
com.ibm.commerce.telesales.ui.impl.orderItemPageTableDefinition.default=com.example.commerce.telesales.myNewPracticePlugin.customizedItemTable com.ibm.commerce.telesales.ui.impl.orderItemsPaginationPageManagedComposite=com.example.commerce.telesales.myNewPracticePlugin.myNewExtensionsPluginManagedComposite com.ibm.commerce.telesales.findStore=com.example.commerce.telesales.myNewPracticePlugin.request