WebSphere Commerce EnterpriseWebSphere Commerce Professional

Extending the UserData element

Use the UserData element when you want to use the extra fields in the database to add new custom data to the existing Sales Center messages without making any changes to the WebSphere Commerce Server and without changing the schema definition of the request/response business object document (BOD).

About this task

To add additional name-value pairs to the UserData element:

Procedure

  1. Add the parameters to the model object that is being passed to the service request handler through the TelesalesProperties. Any properties marked as being user data properties will be added to the UserData element automatically. Ensure that you use the ModelObject.addUserDataProperty method to indicate that a property should be included in the UserData element. In this example, the ModelObject is Customer, and a new parameter "userField1" is passed to the create user request using the UserData element on the Business Object Document. This is part of an extension of the customer editor:
    
    package extensions;
    
    import com.ibm.commerce.telesales.core.TelesalesProperties;
    import com.ibm.commerce.telesales.model.Customer;
    import com.ibm.commerce.telesales.ui.impl.editors.CustomerEditor;
    
    public class ExtendedCustomerEditor extends CustomerEditor {
    
            protected TelesalesProperties getCreateCustomerParameters()
    {
                    TelesalesProperties parms =
    super.getCreateCustomerParameters();
                    Customer customer = (Customer)
    parms.get("customer");
                    customer.setData("userField1", "custom data");
                    customer.addUserDataProperty("userField1");
                    return parms;
            }
    }
    
  2. Use the appropriate extension point to support your customization. In this example we are sending custom data from the customer editor, so we use the editors extension point:
    
    <?xml version="1.0" encoding="UTF-8"?>
    <?eclipse version="3.0"?>
    <plugin>
    
       <extension
    point="com.ibm.commerce.telesales.configurator">
          <configurator path="config"/>
       </extension>
       <extension
             point="org.eclipse.ui.editors">
          <editor
                name="customerEditorName"
                icon=""
                
                id="extensions.customerEditor">
          </editor>
       </extension>
    
    </plugin>
    
  3. Use the system configurator to support your customization of the user interface element that is sending the additional data. In this example we are sending the additional data from the customer editor:
    
    com.ibm.commerce.telesales.customerEditor=extensions.customerEditor
    

Results

Note: The steps mentioned above are necessary to reflect back the customization that user has done. That is, to show the customized UI rather than the default UI, and customer.setdata are used to set the appropriate key value pair so that server can recognize that as a part of UserData.