You can add, modify, and delete cost center data for a user’s profile through the CommerceProfileTools class. Cost centers are assigned to either a user or an organization (or sub-organization). A cost center will consist of an identifier and a description.

There are two ways in which cost centers can be added, edited, or deleted within a profile:

The methods of CommerceProfileTools allow you to add, modify, and delete of cost centers from a profile.

Setting up HTML forms for customers to use to make changes to the cost centers within their own profile is done using the CommerceProfileFormHandler class. The following table describes the properties of the CommerceProfileFormHandler class:

Property

Description

AddCostCenterIdentifier

Stores the identifier, or name, of a new cost center to be added to the repository.

AddCostCenterDescription

Stores the description of a new cost center to be added.

EditCostCenterIdentifier

Stores the identifier of a cost center that is to be modified.

EditCostCenterDescription

Stores the description that will be the new value for the description of the cost center identified by EditCostCenterIdentifier.

RemoveCostCenterIdentifier

Stores the identifier of the cost center to remove.

DefaultCostCenter

Boolean value that stores whether or not the given cost center should become the user’s default cost center.

AddCostCenterSuccessURL

Stores the name of the JSP the user is to be taken to after successfully adding a cost center.

AddCostCenterErrorURL

Stores the name of the JSP the user is to be taken to after an error occurs while attempting to add a cost center.

EditCostCenterSuccessURL

Stores the name of the JSP the user is to be taken to after successfully editing a cost center.

EditCostCenterErrorURL

Stores the name of the JSP the user is to be taken to after an error occurs while attempting to edit a cost center.

RemoveCostCenterSuccessURL

Stores the name of the JSP the user is to be taken to after successfully removing a cost center.

RemoveCostCenterErrorURL

Stores the name of the JSP the user is to be taken to after an error occurs while attempting to remove a cost center.

The adding, editing and removing cost centers can be performed by calling handleAddCostCenter, handleEditCostCenter, and handleRemoveCostCenter.

The following JSP example creates a form that allows a customer to add a cost center:

<h1>Add Cost Center</h1>
<dsp:form action="done.jsp" method="post">
  <dsp:input bean="ProfileFormHandler.AddCostCenterSuccessURL" value="success.jsp"
             type="hidden"/>
  <dsp:input bean="ProfileFormHandler.AddCostCenterErrorURL" value="error.jsp"
             type="hidden"/>
  Name: <dsp:input bean="ProfileFormHandler.AddCostCenterIdentifier"
             type="text"/><P>
  Description: <dsp:input bean="ProfileFormHandler.AddCostCenterDescription"
             type="text"/><P>
  <dsp:input bean="ProfileFormHandler.DefaultCostCenter" value="true"
             type="checkbox"/> Make default<P>
  <dsp:input bean="ProfileFormHandler.AddCostCenter" value="Add Cost Center"
             type="submit"/><P>
</dsp:form>

The following JSP example creates a form that allows a customer to edit a cost center:

<h1>Edit Cost Center</h1>
<dsp:form action="done.jsp" method="post">
  <dsp:input bean="ProfileFormHandler.EditCostCenterSuccessURL"
            value="success.jsp" type="hidden"/>
  <dsp:input bean="ProfileFormHandler.EditCostCenterErrorURL" value="error.jsp"
             type="hidden"/>
  Name: <dsp:input bean="ProfileFormHandler.EditCostCenterIdentifier"
                   type="text"/><P>
  New Description: <dsp:input bean="ProfileFormHandler.EditCostCenterDescription"
                              type="text"/><P>
  <dsp:input bean="ProfileFormHandler.DefaultCostCenter" value="true"
             type="checkbox"/>
  Make default<P>
  <dsp:input bean="ProfileFormHandler.EditCostCenter" value="Edit Cost Center"
             type="submit"/><P>
</dsp:form>

The following JSP example creates a form that allows a customer to remove a cost center:

<h1>Remove Cost Center</h1>
<dsp:form action="done.jsp" method="post">
  <dsp:input bean="ProfileFormHandler.RemoveCostCenterSuccessURL"
            value="success.jsp" type="hidden"/>
  <dsp:input bean="ProfileFormHandler.RemoveCostCenterErrorURL" value="error.jsp"
             type="hidden"/>
  Name: <dsp:input bean="ProfileFormHandler.RemoveCostCenterIdentifier"
                   type="text"/><P>
  <dsp:input bean="ProfileFormHandler.RemoveCostCenter" value="Remove Cost Center"
             type="submit"/><P>
</dsp:form>

Copyright © 1997, 2012 Oracle and/or its affiliates. All rights reserved. Legal Notices