Samples > Sample stores > Consumer direct sample store > IBM Gift Center for the Consumer direct sample store > IBM Gift Center > Customize the component and data service layers


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

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

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.

Related reference

Create BOD commands


+

Search Tips   |   Advanced Search