Tutorials > Sales Center > Extend a page in an editor
Modify the OrderGiftDataBean class
This section refers to modifying the OrderGiftDataBean class.
In the prerequisite Extending the object model and modifying an existing task command tutorial, you created a database table called XORDGIFT and a corresponding data bean called OrderGiftDataBean. In the OrderGiftDataBean class, the populate method copies the gift message information from the database to the data bean. If the gift message information for an order is not found in the XORDGIFT table, a finder exception is thrown.
In the IBM Sales Center, it is possible to create an order without any gift message information then save or submit the order. In this case, when the order information is loaded, the OrderGiftDatabean class' populate method will not find any gift message information in the XORDTABLE. Instead of throwing a finder exception, we will set the data bean's gift message fields to null.
To modify the OrderGiftDataBean class:
- Open WebSphere Commerce Developer.
- In the Enterprise Explorer view, navigate to Other Projects > WebSphereCommerceServerExtsnsionsLogic > src > com.ibm.commerce.sample.databeans.
- Open the OrderGiftDataBean.java class for editing.
- Within the populate class, navigate to the following try-catch block:
try { // load the data from the access bean setInitKey_ordersId(getOrderId()); refreshCopyHelper(); } catch (javax.naming.NamingException e) { throw new ECSystemException(ECMessage._ERR_NAMING_EXCEPTION, "OrderGiftDataBean", "populate"); } catch (javax.ejb.FinderException e) { throw new ECSystemException(ECMessage._ERR_FINDER_EXCEPTION, "OrderGiftDataBean", "populate"); } catch (javax.ejb.CreateException e) { throw new ECSystemException(ECMessage._ERR_CREATE_EXCEPTION,"OrderGiftDataBean", "populate"); } catch (java.rmi.RemoteException e) { throw new ECSystemException(ECMessage._ERR_NAMING_EXCEPTION, "OrderGiftDataBean", "populate"); } }
- Replace the line throw new ECSystemException(ECMessage._ERR_FINDER_EXCEPTION, "OrderGiftDataBean", "populate"); with the following code:
/* * Set the gift message fields to null when they are not found in the database. * This case occurs when an order without gift message information is created and saved or submitted in * the IBM Sales Center. */ setReceiptName(null); setSenderName(null); setMsgField1(null); setMsgField2(null);
- Save the changes.