Tutorials > Sales Center > Extend a page in an editor

< Previous | Next >


Send gift information from the server to the client

This section refers to sending gift information from the server to the client.

After you submit an order with gift information, you might want to view that order again through the IBM Sales Center, for example, if the customer calls back later and wants to confirm the gift message. In this step of the tutorial we will add customized reply builders to send the gift information from the server to the client. The customized reply builders are commands that add the gift message information to the appropriate reply BODs using the UserData tag. The fields on the Order Summary page of the order editor that were used to capture the message information will be used to display message information for existing orders. The same order editor can be used to both capture new orders, as well as view existing orders. You will perform this step of the tutorial using WebSphere Commerce Developer, the development environment for the server.

Determine which commands run when the Order Editor displays by examining the TelesalesRegistry.xml file:


Procedure

  1. Navigate to WC_EAR/xml/messaging.

  2. Open the TelesalesRegistry.xml file.

  3. Locate the following text: <Noun name="SalesOrder"> <Verb name="Get"> <ClassName>com.ibm.commerce.telesales.messaging.bodreply.ShowSalesOrder</ClassName> </Verb> <Verb name="Create"> <ClassName>com.ibm.commerce.telesales.messaging.bodreply.ConfirmSalesOrder</ClassName> </Verb> <Verb name="Sync"> <ClassName>com.ibm.commerce.telesales.messaging.bodreply.ConfirmSalesOrder</ClassName> </Verb> <Verb name="Cancel"> <ClassName>com.ibm.commerce.telesales.messaging.bodreply.ConfirmSalesOrder</ClassName> </Verb> </Noun>

By examining the text you can determine that the command com.ibm.commerce.telesales.messaging.bodreply.ShowSalesOrder runs when the IBM Sales Center client gets information about an order, and com.ibm.commerce.telesales.messaging.bodreply.ConfirmSalesOrder runs when the IBM Sales Center client creates, synchronizes with or cancels an order. In this tutorial, we will extend these commands to add the gift message data.

Add the custom reply builders:

  1. Open WebSphere Commerce Developer if it is not already running.

  2. In the Enterprise Explorer view, navigate to Other Projects > WebSphereCommerceServerExtensionsLogic.

  3. Right-click the src folder and click New > Package.

  4. In the Name field, enter com.ibm.commerce.sample.messaging.bodreply.

  5. Click Finish.

  6. Right-click the com.ibm.commerce.sample.messaging.bodreply package and click New > Class.

  7. In the Name field, enter ExtendedShowSalesOrder.

  8. In the Superclass field, enter or browse to com.ibm.commerce.telesales.messaging.bodreply.ShowSalesOrder.

  9. Keep all other default values and click Finish. The ExtendedShowSalesOrder class opens for editing.

  10. Add the following method to the class: protected Element createSalesOrderElement(OrderBaseSearchResultBean orderSearchResult, Element parentElement) throws ECException { OrderDataBean orderBean = orderSearchResult.getOrderBaseInformation(); if (orderBean != null) { String orderId = orderBean.getOrderId(); try { OrderGiftDataBean OrderGiftDataBean = new OrderGiftDataBean(); OrderGiftDataBean.setOrderId(new Long(orderId)); DataBeanManager.activate(OrderGiftDataBean, getCmdCtxt()); orderSearchResult.addUserDataField("receiptName",OrderGiftDataBean.getReceiptName()); orderSearchResult.addUserDataField("senderName",OrderGiftDataBean.getSenderName()); orderSearchResult.addUserDataField("msgField1",OrderGiftDataBean.getMsgField1()); orderSearchResult.addUserDataField("msgField2",OrderGiftDataBean.getMsgField2()); } catch (javax.ejb.FinderException e) { throw new ECSystemException(ECMessage._ERR_CREATE_EXCEPTION, "OrderGiftDataBean", "OrderGiftDataBean(ab)"); } catch (javax.naming.NamingException e) { throw new ECSystemException(ECMessage._ERR_NAMING_EXCEPTION, "OrderGiftDataBean", "OrderGiftDataBean(ab)"); } catch (java.rmi.RemoteException e) { throw new ECSystemException(ECMessage._ERR_REMOTE_EXCEPTION, "OrderGiftDataBean", "OrderGiftDataBean(ab)"); } catch (javax.ejb.CreateException e) { throw new ECSystemException(ECMessage._ERR_CREATE_EXCEPTION, "OrderGiftDataBean", "OrderGiftDataBean(ab)"); } } Element salesOrderElement = super.createSalesOrderElement(orderSearchResult, parentElement); return salesOrderElement; }

  11. Click Source > Organize Imports to add required import statements. When prompted choose the org.w3c.dom.Element import.

  12. Save the changes.

  13. Right-click the com.ibm.commerce.sample.messaging.bodreply package and click New > Class.

  14. In the Name field, enter ExtendedConfirmSalesOrder.

  15. In the Superclass field, enter or browse to com.ibm.commerce.telesales.messaging.bodreply.ConfirmSalesOrder.

  16. Keep all other default values and click Finish. The ExtendedConfirmSalesOrder class opens for editing.

  17. Add the following method to the class: protected Element createSalesOrderElement(OrderBaseSearchResultBean orderSearchResult, Element parentElement) throws ECException { OrderDataBean orderBean = orderSearchResult.getOrderBaseInformation(); if (orderBean != null) { String orderId = orderBean.getOrderId(); try { OrderGiftDataBean OrderGiftDataBean = new OrderGiftDataBean(); OrderGiftDataBean.setOrderId(new Long(orderId)); DataBeanManager.activate(OrderGiftDataBean, getCmdCtxt()); orderSearchResult.addUserDataField("receiptName",OrderGiftDataBean.getReceiptName()); orderSearchResult.addUserDataField("senderName",OrderGiftDataBean.getSenderName()); orderSearchResult.addUserDataField("msgField1",OrderGiftDataBean.getMsgField1()); orderSearchResult.addUserDataField("msgField2",OrderGiftDataBean.getMsgField2()); } catch (javax.ejb.FinderException e) { throw new ECSystemException(ECMessage._ERR_CREATE_EXCEPTION, "OrderGiftDataBean", "OrderGiftDataBean(ab)"); } catch (javax.naming.NamingException e) { throw new ECSystemException(ECMessage._ERR_NAMING_EXCEPTION, "OrderGiftDataBean", "OrderGiftDataBean(ab)"); } catch (java.rmi.RemoteException e) { throw new ECSystemException(ECMessage._ERR_REMOTE_EXCEPTION, "OrderGiftDataBean", "OrderGiftDataBean(ab)"); } catch (javax.ejb.CreateException e) { throw new ECSystemException(ECMessage._ERR_CREATE_EXCEPTION, "OrderGiftDataBean", "OrderGiftDataBean(ab)"); } } Element salesOrderElement = super.createSalesOrderElement(orderSearchResult, parentElement); return salesOrderElement; }

  18. Click Source > Organize Imports to add required import statements. When prompted choose the com.ibm.commerce.telesales.messaging.bodreply.ShowSalesOrder and org.w3c.dom.Element imports.

  19. Save the changes.

  20. Point to the new implementation:

    1. In the file system, navigate to WC_EAR/xml/messaging.

    2. Create a new file called TelesalesRegistry-ext.xml.

    3. Add the following text to the class: <WCTBodResponseBuilderRegistry> <Noun name="SalesOrder"> <Verb name="Get"> <ClassName>com.ibm.commerce.sample.messaging.bodreply.ExtendedShowSalesOrder</ClassName> </Verb> <Verb name="Sync"> <ClassName>com.ibm.commerce.sample.messaging.bodreply.ExtendedConfirmSalesOrder</ClassName> </Verb> </Noun> </WCTBodResponseBuilderRegistry>

    4. Save the changes and close the file.

    5. Navigate to WC_EAR/xml/config

    6. Open the wc-server.xml file for editing.

    7. Locate the following text: <component compClassName="com.ibm.commerce.telesales.configuration.TelesalesRegistryComponentConfiguration" enable="true" name="Telesales Response Builder Registry Configuration"> <property baseRegistryFilePath="messaging" customRegistryFileName="" customRegistryFilePath="" display="false" enableBaseRegistryOverride="false"/> </component>

    8. Modify the customRegistryFileName and customRegistryFilePath values... <component compClassName="com.ibm.commerce.telesales.configuration.TelesalesRegistryComponentConfiguration" enable="true" name="Telesales Response Builder Registry Configuration"> <property baseRegistryFileName="TelesalesRegistry.xml" baseRegistryFilePath="messaging" customRegistryFileName="TelesalesRegistry-ext.xml" customRegistryFilePath="messaging" display="false" enableBaseRegistryOverride="true"/> </component>

  21. Start or restart the WebSphere Commerce Test Server if it is running. A server restart is required to pick up changes made to wc-server.xml.

  22. To test the changes, open the order you created in Test the changes. The gift order information you entered should display in the input fields.

< Previous | Next >


+

Search Tips   |   Advanced Search