Develop > Presentation layer > Work with Web service feeds > Pass custom parameters to an e-Marketing Spot Atom feed
Extend the Atom feed Java class to support the new parameter
Create a Java class that extends from the MarketingSpotData Java class.
To add the business logic required to support the custom parameter, override the buildMarketingTriggerParameters method in the class. The new class must detect the custom parameter in the URL. If the parameter is present, the new class must add the parameter and value to the list of trigger parameters passed to the marketing services.
Before you begin
Review the MarketingSpotData class.
Procedure
- Open WebSphere Commerce Developer and switch to the Enterprise Explorer view.
- Add the Rest project to your build path:
- Right-click the WebSphereCommerceServerExtensionsLogic project; then click Properties.
- From the navigation pane, click Java Build Path.
- Click the Projects tab; then click Add.
- Click the Rest project; then click OK.
- Click OK to save and close the Properties page.
- Create a package for the new class:
- Navigate to WebSphereCommerceServerExtensionsLogic > src.
- Right-click the src folder; then click New > Package.
- In the Name field, type:
com.your_company_name.commerce.marketing.rest.resources
- Click Finish.
- In the new package, create a Java class called MarketingSpotDataExt that extends from MarketingSpotData.
To add logic to support the custom URL parameters, override the buildMarketingTriggerParameters method. See the example at the end of this procedure.
- Save the new class file.
- Register the new Java class to the RESTful framework for Web service feeds:
- Open the properties file at this path:
WCDE_INSTALL/workspace/Rest/WebContent/WEB-INF/config/resources-ext.properties
- In the properties file, add the fully qualified name of the Java class you created, for example:
com.mycompany.commerce.marketing.rest.resources.MarketingSpotDataExt
- Save and close the file.
- Restart the WebSphere Commerce server.
Example
The following is an example Java class created to support a custom loyaltyId parameter:
package com.mycompany.commerce.marketing.rest.resources; import java.util.Map; import javax.ws.rs.core.MultivaluedMap; import com.ibm.commerce.marketing.rest.resources.MarketingSpotData; public class MarketingSpotDataExt extends MarketingSpotData { private static final String PARAM_LOYALTY_ID = "loyaltyId"; protected String buildMarketingTriggerParameters(Map<String, String> parameters) { // Get all parameters from the URI. MultivaluedMap<String, String> map = uri.getQueryParameters(); // Prepare all the additional parameters for the expression. String loyaltyIdValue = map.getFirst(PARAM_LOYALTY_ID); if (loyaltyIdValue != null && loyaltyIdValue.length() > 0) { parameters.put(PARAM_LOYALTY_ID, loyaltyIdValue); } return super.buildMarketingTriggerParameters(parameters); } }
Next topic: Customize the store JSP file to pass the custom parameter to the Atom feed URL