Creating the price rule element task command
Create a new task command interface and its associated implementation class for your new price rule element. The task command performs the work for the price rule element and validates parameters.
Before you begin
- Price rule element task commands
- com.ibm.commerce.price.rule.commands.element.PriceRuleElementCmdImpl class
- com.ibm.commerce.price.rule.commands.element.PriceRuleElementCmd interface
About this task
The price rule element task command must be a class that implements the PriceRuleElementCmd interface and should extend from the PriceRuleElementCmdImpl class.
Procedure
- Open WebSphere Commerce Developer and switch to the Enterprise Explorer view.
- Create a package for your task command files:
- In the new package, create a new interface class for your
price rule element task command that extends from the PriceRuleElementCmd
interface.
Make sure this class name matches what you specified in the runtime XML when you created the price rule element template definition: see the name parameter for the
<class>
element.Here is an example of a task command for a condition that determines whether the customer registered on, before, or after a specific date, and is therefore entitled to special prices:
package com.mycompany.commerce.price.rule.commands.element; import com.ibm.commerce.price.rule.commands.element.PriceRuleElementCmd; public interface RegistrationTimeConditionElementCmd extends PriceRuleElementCmd { public final static String defaultCommandClassName = RegistrationTimeConditionElementCmdImpl.class.getName(); }
- In the new package, create a task command implementation
that extends from the PriceRuleElementCmdImpl class. This task command
must implement the interface that you defined in the previous step.
Give the class a name that uses this syntax: pricerule_element_nameElementCmdImpl;
for example,
RegistrationTimeConditionElementCmdImpl
.For conditions and actions, this task command implementation must implement the method performExecute. The task command implementation can also implement the method validateParameters to validate that the element has all the required user interface parameters.
- For any server-side error messages in the task command,
create a new message key class:
- Create a properties file to define the server-side
error message text: