Tutorials > Sales Center > Add an editable column to the Order Items table by creating a new widget manager

< Previous | Next >


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 handler

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

  1. In the Package Explorer view, navigate to the com.example.commerce.telesales.myNewPracticePlugin > src project.

  2. Right-click the com.example.commerce.telesales.myNewPracticePlugin package.

  3. Select New > class.

  4. In the Name field, enter ExtendedGetStoreRequest.

  5. Next to the Superclass field, click Browse.

  6. In the Choose a type field, enter GetStoreRequest and click OK.

  7. Click Finish.

  8. 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);
    
                    }
            }
    
    }
    

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

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

  2. Use the system configurator extension point to indicate that the new implementation is to be used instead of the default IBM Sales Center implementation:

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

< Previous | Next >


+

Search Tips   |   Advanced Search