WebSphere Commerce EnterpriseIntroduced in Feature Pack 2

Creating and registering a serialization JSP file for the price rule element

Create and register a serialization JSP file to take the authoring elements from the PRELEMENT and PRELEMENTATTR tables for your new price rule element and display them in the Management Center user interface. Business users can then set the properties for the price rule element when creating a price rule.

Before you begin

Review the following topic to understand the format of the XML response that the server returns:

About this task

When a business user opens a price rule, the parent serialization JSP file, GetPriceRuleElements.jsp, calls the serialization JSP file for each price rule element to load the data for the price rule.

If the object definition for your new price rule element includes wcfChildObjectDefinitions or wcfReferenceObjectDefinitions, you must create a new serialization JSP file for your new price rule element; otherwise, you can use the existing generic serialization JSP file, SerializePriceRuleCommonElement.jsp, as is. In both cases, you must register the serialization JSP file in the Struts configuration file for customization, struts-extension.xml. This file is initially empty and takes precedence over all Struts configuration files.

Procedure

  1. Open WebSphere Commerce Developer and switch to the Enterprise Explorer view.
  2. If you need a new serialization JSP file, complete the following steps; otherwise, skip to step 3:
    1. Create a directory to store your new JSP file.
      Use a directory structure similar to the following example:

      LOBTools/WebContent/jsp/your_company_name/price

    2. Create a JSP file with this syntax: SerializePriceRulepricerule_element_name.jsp, for example, SerializePriceRuleRegistrationTimeCondition.jsp.
    3. Define the new serialization JSP file.
      The following is a sample serialization JSP file for a price rule element:
      <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
      <%@ taglib uri="http://commerce.ibm.com/foundation" prefix="wcf"%>
      
      <object objectType="RegistrationTimeCondition"> 1
          <parent><object objectId="${element.parentElementIdentifier.name}"/></parent> 2a
          <elemTemplateName><wcf:cdata data="${element.elementTemplateIdentifier.externalIdentifier.name}"/></elemTemplateName>2b
          <elementName>${element.elementIdentifier.name}</elementName> 2c
          <sequence>${element.elementSequence}</sequence> 2d
          <c:forEach var="elementVariable" items="${element.elementAttribute}"> 3
              <${elementVariable.name}><wcf:cdata data="${elementVariable.value}"/></${elementVariable.name}>
          </c:forEach>
          <c:forEach var="userDataField" items="${element.userData.userDataField}"> 4
              <x_${userDataField.typedKey}><wcf:cdata data="${userDataField.typedValue}"/></x_${userDataField.typedKey}>
          </c:forEach>
      </object>

      The following describes the lines with black numbered callouts:

      • 1 The objectType value must match the objectType defined in the object definition for this price rule element.
      • 2a-d These four elements are mandatory; include the lines of code exactly as shown in the previous example with no changes.
      • 3 The <c:forEach> element loops through all of the values stored for the price rule element in the PRELEMENTATTR table and returns all of the names (in elementVariable.name) and values (in elementVariable.value).
      • 4 The <c:forEach> element returns any customizations to the PriceRule noun (PriceRuleElement part) in the UserData field. If you customized the Management Center to add UserData into your noun, this element ensures that this user data is transformed into the Management Center object.

      This JSP must also return any wcfChildObjectDefinitions and wcfReferenceObjectDefinitions. To see examples of serialization JSP files that do so, review a default serialization JSP file for a similar price rule element. The default files are named SerializePriceRulepricerule_element_name.jsp, for example, SerializePriceRuleCatalogConditionElement.jsp. The default files are stored at this path:

      LOBTools/WebContent/jsp/commerce/price/restricted/serialize/

    4. Save and close the new serialization JSP file.
  3. Open the Struts configuration file, struts-extension.xml.
    The file is stored at this path:

    LOBTools/WebContent/WEB-INF

  4. Add a new action mapping to register the serialization JSP file:
    • If you created your own serialization JSP file, your action mapping should use the following syntax:
      <action path="/SerializePriceRuleElement-objectType_value" 
      include="/jsp/your_company_name/price/name_of_serialization_jsp_file.jsp" />

      where

      • objectType_value is the value of the objectType attribute defined in the object definition for this price rule element
      • name_of_serialization_jsp_file is the name you gave to the custom serialization JSP file for your new price rule element in an earlier step of this procedure.
    • If you are using the generic serialization JSP file, your action mapping should use the following syntax:
      <action path="/SerializePriceRuleElementobjectType_value" 
      include="/jsp/commerce/price/restricted/serialize/SerializePriceRuleCommonElement.jsp" />

      where objectType_value is the value of the objectType attribute defined in the object definition for this price rule element.

    Here are a couple of tips:
    • If you copied code from an existing serialization JSP file, you must update the paths as appropriate for any included JSP files.
    • If you change your serialization JSP file, make sure to edit the GetPriceRuleElements.jsp file. You do not need to make any changes to the GetPriceRuleElements.jsp file; just save it to change the file modification timestamp. The GetPriceRuleElements.jsp file includes the serialization JSP files, so this will ensure that your serialization JSP file changes are picked up.
  5. Restart the WebSphere Commerce test server to make the new configuration available.

What to do next

After you complete your customization:
  1. Right-click LOBTools Project; then click Build OpenLaszlo Project to produce an updated ManagementCenter.swf file under the workspace_dir\LOBTools\WebContent directory. This setting is the default environment setting.
  2. Test your changes by viewing them in the Management Center, using this URL: https://hostname:8000/lobtools.
  3. Deploy your changes to your production environment.