We used the B2BRepositoryFormHandler
to provide functionality in the Motorprise Company Admin. After administrators have logged in and selected a business unit, they can manage the following within that business unit:
Functionality | Description |
---|---|
Shipping Addresses | Create new ones. Edit or delete existing ones. |
Default Shipping Address | Select a default shipping address from the list of existing shipping addresses. |
Billing Addresses | Create new ones. Edit or delete existing ones. |
Default Billing Address | Select a default billing address from the list of existing billing addresses. |
Credit Cards | Create new ones. |
Cost Centers | Create new ones. Edit or delete existing ones. |
Approvals | Make them required or not. |
Payment Methods | Authorize or restrict the use of invoices and credit cards. |
For example, the following code, from shipping_address_create.jsp
, creates a new shipping address and adds that shipping address to the organization to which the admin belongs. This code is explained below sequentially.
In the example, a new repository item of type contactInfo
is created and is assigned to the shippingAddrs
property of the repository item whose type is organization
and whose repository ID is Profile.currentOrganization.repositoryid
.
address1
is a contactInfo
property and can be accessed using the value
dictionary of the B2BRepositoryFormHandler
. It is also a part of the requiredFields
property.
We use the updateItemDescriptorName
property to set the name of the item type to which we are adding the newly created shipping address. In this case , it is organization
.
<%-- main content area --%> <td valign="top" width=745> <dsp:include page="../common/FormError.jsp" flush="true"></dsp:include> <dsp:form action="shipping_edit.jsp" method="post"> <dsp:input bean="B2BRepositoryFormHandler.itemDescriptorName" type="hidden" value="contactInfo"/> <dsp:input bean="B2BRepositoryFormHandler.updateItemDescriptorName" type="hidden" value="organization"/>
We use the updateRepositoryId
property to set the repository ID of the item to which the new address is being added. In the example below, this is the repository ID of the parent organization, Profile.currentOrganization.repositoryid
.
updatePropertyName
determines the property of the parent organization to which the newly created shipping address is to be added. In this example, it is set to shippingAddrs
, which is the parent organization’s list property that contains a list of shipping addresses.
<dsp:input bean="B2BRepositoryFormHandler.updateRepositoryId" beanvalue="Profile.currentOrganization.repositoryid" type="hidden"/> <dsp:input bean="B2BRepositoryFormHandler.updatePropertyName" type="hidden" value="shippingAddrs"/>
If one or more fields in the form must be a non-null value, we set RequiredFields
so that the user is always forced to enter a value before submitting the form.
If the property being modified is a map instead of a list, as in this case with shippingAddrs
, then a key must be provided for the new map entry. This is specified by the updateKey
property.
<dsp:input bean="B2BRepositoryFormHandler.requireIdOnCreate" type="hidden" value="false"/> <dsp:input bean="B2BRepositoryFormHandler.requiredFields" name="hiddenFields" type="hidden" value="COMPANYNAME"/> <dsp:input bean="B2BRepositoryFormHandler.requiredFields" name="hiddenFields" type="hidden" value="ADDRESS1"/> <dsp:input bean="B2BRepositoryFormHandler.requiredFields" name="hiddenFields" type="hidden" value="CITY"/> <dsp:input bean="B2BRepositoryFormHandler.requiredFields" name="hiddenFields" type="hidden" value="POSTALCODE"/> <dsp:input bean="B2BRepositoryFormHandler.createErrorURL" type="hidden" value="shipping_address_create.jsp"/> <dsp:input bean="B2BRepositoryFormHandler.createSuccessURL" type="hidden" value="shipping_edit.jsp"/> <table border=0 cellpadding=4 width=80%> <tr> <td colspan=2><dsp:img src="../images/d.gif" vspace="0"/></td> </tr> <tr> <td colspan=2 valign="top"><span class=big>Company Administration</span> <br><span class=little><dsp:valueof bean="Profile.currentOrganization.name" /></span></td> </tr> <tr> <td colspan=2><dsp:img src="../images/d.gif" vspace="0"/></td> </tr> <tr> <td colspan=2 valign="top"> <table width=100% cellpadding=3 cellspacing=0 border=0> <tr> <td class=box-top> Create Shipping Address</td> </tr> </table> </td> </tr> <tr> <td colspan=2><span class=small>The nickname field is used to identify this address when you don't have access to the full address. It should be unique from all other shipping address nicknames. It can be the same as the company name.</span></td> </tr> <tr> <td colspan=2><dsp:img src="../images/d.gif" vspace="0"/></td> </tr> <tr> <td align=right><span class=smallb>Nickname</span></td> <td width=75%><dsp:input bean="B2BRepositoryFormHandler.updateKey"