Extending existing code
As an example of extending existing IBM Gift Center code, this section describes how to extend the ValidateGiftRegistryValuesCmd class for the update gift registry service, while extending the class with a new one called MyValidateGiftRegistryValuesCmd. Thus, update gift registry will include the MyValidateGiftregistryValuesCmd command, in addition to the existing commands, as follows:
The extended class will look like this:
public class MyValidateGiftRegistryValuesCmdImpl extends ValidateGiftRegistryValuesCmdImpl implements ValidateGiftRegistryValuesCmd { public void performExecute() throws ECException { super.performExecute(); validateGiftRegistry(); // call our specific validate } protected void validateGiftRegistry() { super.validateGiftRegistry(); // Your custom code in here } }Once this new class is created, you can have the UpdateGiftRegistryCmd controller command call it by updating the
CMDREG WebSphere Commerce database table as follows:STOREENT_ID = store_ID INTERFACENAME = 'com.ibm.commerce.component.giftregistry.commands. ValidateGiftRegistryValuesCmd' CLASSNAME = 'com.ibm.commerce.component.giftregistry.commands. MyValidateGiftRegistryValuesCmdImpl'where store_ID is the unique ID for your WebSphere Commerce store, such as 10001.
The change in the CMDREG table tells the UpdateGiftRegistryCmd command to call the new MyValidateGiftRegistryValuesCmd command. The command will start in the performExecute() method. You can also add validation or remove function as required.
(C) Copyright IBM Corporation 1996, 2006. All Rights Reserved.