Like editing an address, when the customer clicks the remove this hyperlink to delete an alternate shipping address, the setRemoveAddress() method is passed the target address, and the handleRemoveAddress() method does the actual removal.

The JSP sample below was taken from address_book.jsp and abbreviated for the purpose of demonstrating how to delete an address using a link. The ForEach servlet bean iterates over the secondaryAddress property, which is a java.util.Map. When ForEach iterates over a Map or Dictionary or Hashtable (or any multi-valued object that contains keys and values), it binds the param:key to each key in the object in the very same way that it binds element to each value in the object. In the case of the secondaryAddresses property, a link is generated which, when clicked, sets the value of property removeAddress to the key or nickname of the address and then invokes the method handleRemoveAddress.

<dsp:getvalueof id="requestURL" idtype="java.lang.String"
     bean="/OriginatingRequest.requestURI">
<dsp:droplet name="ForEach">
  <dsp:param bean="Profile.secondaryAddresses" name="array"/>
  <dsp:oparam name="output">
    > <dsp:a bean="B2CProfileFormHandler.removeAddress"
           href="<%=requestURL%>" paramvalue="key">remove this</dsp:a>
  </dsp:oparam>
</dsp:droplet>
</dsp:getvalueof>

Note that all the handlers in the B2CprofileFormHandler class have associated success and error properties. For example, the handleRemoveAddress() method redirects the site visitor to the page identified by removeAddressSuccessURL() if the address is successfully removed, and to the page identified by removeAddressErrorURL() if an error occurred during the removal process. In both cases, redirection only occurs if the property has a non-null value otherwise this user is sent to the page defined by the action attribute.

 
loading table of contents...