Tutorials > Sales Center > Extend a page in an editor
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
- Navigate to WC_EAR/xml/messaging.
- Open the TelesalesRegistry.xml file.
- 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:
- Open WebSphere Commerce Developer if it is not already running.
- In the Enterprise Explorer view, navigate to Other Projects > WebSphereCommerceServerExtensionsLogic.
- Right-click the src folder and click New > Package.
- In the Name field, enter com.ibm.commerce.sample.messaging.bodreply.
- Click Finish.
- Right-click the com.ibm.commerce.sample.messaging.bodreply package and click New > Class.
- In the Name field, enter ExtendedShowSalesOrder.
- In the Superclass field, enter or browse to com.ibm.commerce.telesales.messaging.bodreply.ShowSalesOrder.
- Keep all other default values and click Finish. The ExtendedShowSalesOrder class opens for editing.
- 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; }
- Click Source > Organize Imports to add required import statements. When prompted choose the org.w3c.dom.Element import.
- Save the changes.
- Right-click the com.ibm.commerce.sample.messaging.bodreply package and click New > Class.
- In the Name field, enter ExtendedConfirmSalesOrder.
- In the Superclass field, enter or browse to com.ibm.commerce.telesales.messaging.bodreply.ConfirmSalesOrder.
- Keep all other default values and click Finish. The ExtendedConfirmSalesOrder class opens for editing.
- 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; }
- 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.
- Save the changes.
- Point to the new implementation:
- In the file system, navigate to WC_EAR/xml/messaging.
- Create a new file called TelesalesRegistry-ext.xml.
- 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>
- Save the changes and close the file.
- Navigate to WC_EAR/xml/config
- Open the wc-server.xml file for editing.
- 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>
- 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>
- 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.
- 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.