In WCS - Command represents a java class.
Task Command represents a small piece of logic, i.e., it performs small tasks.
Below demonstration doesn't perform any logic, we just hardcode values and try to retrieve them from CommandControl class.
Steps to create a new Task Commnd:
1)OpenWebSphereCommerceServerExtensionsLogic->src->create package->com.myCompany.commands->finish
2)Create an Interface - Right click on package->New->Interface. give interface name as MyCatalogTaskCmd
3)Extend com.ibm.commerce.command.TaskCommand interface
4)Add a variable in the new Interface as below:
public static final String defaultCommandClassName = "com.myCompany.commands.MyCatalogTaskCmdImpl";
5)Save the interface code.
6)We need to write an implementation class for this interface, Right click on package->New->class->MyCatalogTaskCmdImpl.java
7)Make sure the above class extends com.ibm.commerce.command.TaskCommandImpl
8)And implements MyCatalogTaskCmd interface
9)Add few variables in the class :
private String customerName;
private String address;
private String catalogId;
10)Right click the code and select Source->Generte Getters and Setters
11)Copy the all getter and setter methods from class and past it in Interface, remove implementation brackets and clear errors if any.
12)We need to add a sample values or the above setters in performExecute() method.
By default performExecute() doesn't show up, to make that appear follow below steps:
a)right Click and select Source->Override/Implement Methods
b)select performExecute() from the list and click OK.
13)Add the following code in performExecute() method:
@Override
public void performExecute() throws ECException {
super.performExecute();
setCustomerName("Ravi Garlapati");
setAddress("India");
setCatalogId("WCS 2013");
}
14)This ends the task command code.
Task Command represents a small piece of logic, i.e., it performs small tasks.
Below demonstration doesn't perform any logic, we just hardcode values and try to retrieve them from CommandControl class.
Steps to create a new Task Commnd:
1)OpenWebSphereCommerceServerExtensionsLogic->src->create package->com.myCompany.commands->finish
2)Create an Interface - Right click on package->New->Interface. give interface name as MyCatalogTaskCmd
3)Extend com.ibm.commerce.command.TaskCommand interface
4)Add a variable in the new Interface as below:
public static final String defaultCommandClassName = "com.myCompany.commands.MyCatalogTaskCmdImpl";
5)Save the interface code.
6)We need to write an implementation class for this interface, Right click on package->New->class->MyCatalogTaskCmdImpl.java
7)Make sure the above class extends com.ibm.commerce.command.TaskCommandImpl
8)And implements MyCatalogTaskCmd interface
9)Add few variables in the class :
private String customerName;
private String address;
private String catalogId;
10)Right click the code and select Source->Generte Getters and Setters
11)Copy the all getter and setter methods from class and past it in Interface, remove implementation brackets and clear errors if any.
12)We need to add a sample values or the above setters in performExecute() method.
By default performExecute() doesn't show up, to make that appear follow below steps:
a)right Click and select Source->Override/Implement Methods
b)select performExecute() from the list and click OK.
13)Add the following code in performExecute() method:
@Override
public void performExecute() throws ECException {
super.performExecute();
setCustomerName("Ravi Garlapati");
setAddress("India");
setCatalogId("WCS 2013");
}
14)This ends the task command code.