The registration process in the Pioneer Store collects the information that is stored in the user’s profile. Below is the portion of register.jsp that produces the registration form.

Like most forms in our store, the form submits to itself as directed by the form tag’s action attribute. The form handler method on the server side redirects to the appropriate URL (indicated by the createSuccessUrl property) if the creation is successful. The comments interspersed in the JSP code below explain how the various form fields are used.

  <!-- Assume registration failure -->
  <dsp:getvalueof id="form80" bean="/OriginatingRequest.requestURI"
        idtype="java.lang.String">
<dsp:form action="<%=form80%>" method="POST">

    <!-- Don't assign a new repository id during registration - keep transient
         one:
         This is particular crucial because we store this ID in the ownerId field
         of the addresses (see below). -->
    <dsp:input bean="B2CProfileFormHandler.createNewUser" type="hidden"
         value="false"/>

    <!-- If registration succeeds, go to my profile page and welcome
         new customer there -->
    <dsp:input bean="B2CProfileFormHandler.createSuccessURL" type="hidden"
         value="my_profile.jsp"/>
    <input type="hidden" name="first_time"
         value="yes">

    <!-- User must confirm password when registering -->
    <dsp:input bean="B2CProfileFormHandler.confirmPassword" type="hidden"
         value="true"/>

    <!-- A registered customer is a member -->
    <dsp:input bean="B2CProfileFormHandler.value.member" type="hidden"
         value="true"/>

    <!-- Need to set Registration Date -->

    <table cellspacing=0 cellpadding=0 border=0>

      <!-- Setup gutter and make space -->
      <tr>
        <td width=30%><dsp:img height="1" width="100"
            src="../images/d.gif"/><br></td>
        <td>&nbsp;&nbsp;</td>
        <td><dsp:img height="1" width="300" src="../images/d.gif"/></td>
      </tr>

      <tr valign=top>
        <td width=30%>
          <dsp:droplet name="Switch">
            <dsp:param bean="B2CProfileFormHandler.formError" name="value"/>
            <dsp:oparam name="true">
              <span class=registrationerror>
                <span class=help>There were problems with your
                       registration:</span><p>
                <UL>
                  <dsp:droplet name="ProfileErrorMessageForEach">
                    <dsp:param bean="B2CProfileFormHandler.formExceptions"
                           name="exceptions"/>
                    <dsp:oparam name="output">
                     <LI> <dsp:valueof param="message"/>
                    </dsp:oparam>
                  </dsp:droplet>
                </UL>
              </span>
            </dsp:oparam>
          </dsp:droplet>
        </td>
        <td></td>
        <td>
          <!-- 1. I am: -->
          <table width=100% cellpadding=0 cellspacing=0 border=0>
            <tr><td class=box-top-profile>&nbsp;Me</td></tr>
          </table>
          <p>
          Name (first, middle, last)<br>
          <dsp:input bean="B2CProfileFormHandler.value.firstName" maxlength="40"
                size="15" type="text" required="<%=true%>"/>
          <dsp:input bean="B2CProfileFormHandler.value.middleName" maxlength="40"
                size="10" type="text"/>
          <dsp:input bean="B2CProfileFormHandler.value.lastName" maxlength="40"
                size="15" type="text" required="<%=true%>"/>
          <p>
          Email address <br>
          <dsp:input bean="B2CProfileFormHandler.value.email" maxlength="30"
                size="30" type="text"/>
          <p>
          Daytime telephone<br>
          <dsp:input bean="B2CProfileFormHandler.value.daytimeTelephoneNumber"
                maxlength="20" size="20" type="text"/><br>
          <p>&nbsp;<br>
        </td>
      </tr>

      <tr valign=top>
        <!-- 2. Billing/Main Address -->
        <td width=30%>
          <span class=help>Please provide us with the address where you wish
          to be billed.<p>
          You may use this same address for shipping, or enter
          a separate shipping address below.</span>
        </td>
        <td></td>
        <td>
          <table width=100% cellpadding=0 cellspacing=0 border=0>
            <tr><td class=box-top-profile>&nbsp;My billing address</td></tr>
          </table>
          <p>
          Street address <br>

          <!-- Store the ProfileID in ownerId field of the address.
               This tells us this address "belongs to" (and can be
               edited) by the user. -->
          <dsp:input bean="B2CProfileFormHandler.value.billingAddress.ownerId"
                beanvalue="Profile.id" type="hidden"/>

          <dsp:input bean="B2CProfileFormHandler.value.billingAddress.address1"
                maxlength="30" size="40" type="text" required="<%=true%>"/><br>
          <dsp:input bean="B2CProfileFormHandler.value.billingAddress.address2"
                maxlength="30" size="40" type="text"/><br>
          <table cellpadding=0 cellspacing=0>
            <tr>
              <td>City<br>
                 <dsp:input bean="B2CProfileFormHandler.value.billingAddress.city"
                  maxlength="30" size="20" type="text" required="<%=true%>"/></td>
              <td>&nbsp;State<br>
                  &nbsp;
           <dsp:select bean="B2CProfileFormHandler.value.billingAddress.state">
                   <%@ include file="StatePicker.jspf" %>
                  </dsp:select>
               </td>
              <td>&nbsp;Postal Code<br>
                  &nbsp;
           <dsp:input bean="B2CProfileFormHandler.value.billingAddress.postalCode"
                  maxlength="10" size="10" type="text" required="<%=true%>"/></td>
            </tr>
          </table>
          <table cellpadding=0 cellspacing=0>
            <tr>
              <td>Country<br>
           <dsp:select bean="B2CProfileFormHandler.value.billingAddress.country"
                 required="<%=true%>">
                   <%@ include file="CountryPicker.jspf" %>

                </dsp:select>
              </td>
            </tr>
            <tr>
              <td>Telephone<br>
          <dsp:input bean="B2CProfileFormHandler.value.billingAddress.phoneNumber"
                maxlength="15" size="15" type="text"/></td>
            </tr>
          </table>
          <p>&nbsp;<br>
        </td>
      </tr>

      <tr valign=top>
        <!-- 3. Ship it here: -->
        <td width=30%>
          <span class=help>
            If you know that you will want to ship products to a different
            address, then you may enter an alternate shipping address here.
            <p>If you will always ship products to your billing address,
            then indicate that here.
          </span>
        </td>
        <td></td>
        <td>
          <table width=100% cellpadding=0 cellspacing=0 border=0>
            <tr><td class=box-top-profile>&nbsp;My main shipping address</td></tr>
          </table>
          <p>

          <dsp:input bean="B2CProfileFormHandler.shipToBillingAddress"
                type="radio" checked="<%=true%>" value="true"/> Use billing
                address for shipping<br>
          <dsp:input bean="B2CProfileFormHandler.shipToBillingAddress"
                 type="radio" value="false"/> Use the new address below for
                 shipping
          <p>
          Street address <br>

          <!-- Store the ProfileID in ownerId field of the address.
               This tells us this address "belongs to" (and can be
               edited) by the user. -->
          <dsp:input bean="B2CProfileFormHandler.value.shippingAddress.ownerId"
                 beanvalue="Profile.id" type="hidden"/>

          <dsp:input bean="B2CProfileFormHandler.value.shippingAddress.address1"
               maxlength="30" size="40" type="text"/><br>
          <dsp:input bean="B2CProfileFormHandler.value.shippingAddress.address2"
               maxlength="30" size="40" type="text"/><br>
          <table cellpadding=0 cellspacing=0>
            <tr>
              <td>City<br>
                  <dsp:input
                    bean="B2CProfileFormHandler.value.shippingAddress.city"
                    maxlength="30" size="20" type="text"/></td>
              <td>&nbsp;State<br>
                  &nbsp;<dsp:select
                    bean="B2CProfileFormHandler.value.shippingAddress.state">
                    <%@ include file="StatePicker.jspf" %>

                  </dsp:select>
              </td>
              <td>&nbsp;Postal Code<br>
                  &nbsp;<dsp:input
                    bean="B2CProfileFormHandler.value.shippingAddress.postalCode"
                    maxlength="10" size="10" type="text"/></td>
          </table>
          Country<br>
                <dsp:select
                    bean="B2CProfileFormHandler.value.shippingAddress.country"
                    required="<%=true%>">
                   <%@ include file="CountryPicker.jspf" %>
                </dsp:select>
          <p>&nbsp;<br>
        </td>
      </tr>

      <tr valign=top>
        <!-- 4. Username/password: -->
        <td width=30%>
          <span class=help>When you return to the site, log in with this
          username and password to manage your account information.</span>
          <p>
        </td>
        <td></td>
        <td>
          <table width=100% cellpadding=0 cellspacing=0 border=0>
            <tr><td class=box-top-profile>&nbsp;My profile</td></tr>
          </table>
          <p>
          Choose a username <span class=help>( i.e. 'joeshmoe22' )</span><br>
          <dsp:input bean="B2CProfileFormHandler.value.login" maxlength="20"
               size="15" type="text"/>
          <p>
          Choose a password <span class=help>( i.e. 'pA$$weRD22' )</span><br>
          <dsp:input bean="B2CProfileFormHandler.value.password" maxlength="35"
               size="15" type="password"/><br>
          Enter password again to be sure you have it right<br>
          <dsp:input bean="B2CProfileFormHandler.value.confirmPassword"
               maxlength="35" size="15" type="password"/>
          <p>&nbsp;<br>
        </td>
      </tr>

      <tr valign=top>
        <!-- 5. Optional Personal Data: -->
       <td width=30%>
          <span class=help>These questions are optional, but it's nice if you tell
               us.</span>
        </td>
        <td></td>
        <td>
          <%@ include file="../common/UserPreferencesFormFragment.jspf" %>
        </td>

      <tr valign=top>
        <!-- 6. Submit: -->
        <td width=30%>
        <td></td>
        <td>
          <table width=100% cellpadding=0 cellspacing=0 border=0>
            <tr><td class=box-top-profile>&nbsp;All done?</td></tr>
          </table>
          <p>
          <p>&nbsp;<br>

          <!-- Submit form to handleCreate() handler -->
          <dsp:input bean="B2CProfileFormHandler.create" type="submit" value="
               Register -->   "/>
          <p>
          &nbsp;<br>
        </td>

    </tr>
  </table>
</dsp:form>
</dsp:getvalueof>
The User Profile

The traits of the user profile are defined in the DPS, ATG Consumer Commerce, and the Pioneer Store. Some input fields (first name, last name and several address fields) in the form have the required attribute set to true in the input tag. This means that the ProfileFormHandler ensures that these fields are filled in before performing the registration. If the user submits the form with any of those fields blank, the form handler generates errors that are reported to the user via the formExceptions property. You can make fields required by editing the JSP file. There are two additional required fields, login and password. Unlike the first name and last name fields, which are important at an application level, the fields login and password are needed for the user profiling system to function and so they are set as required in the repository definition file for DPS. If the user fails to fill in login or password before submitting the form, the result from the user’s point of view is the same as leaving the last name blank.

Profile Trait

Defined In

firstName

DPS1

middleName

DPS

lastName

DPS1

email

DPS

login

DPS2

password

DPS2

gender

DPS

dateOfBirth

DPS

daytimeTelephoneNumber

ATG Commerce

size

Pioneer Store

1 required in the input form tags
2 defined as required in the userProfile.xml in the DPS config layer

The input tags that collect these properties are tied to the value property of the ProfileFormHandler component; for example, the firstName property is collected with: <dsp:input bean="B2CProfileFormHandler.value.firstName" type="text" required="<%=true%>"/>

The user profile also defines three user addresses:

Profile Trait

Defined in

homeAddress

DPS

billingAddress

ATG Commerce

shippingAddress

ATG Commerce

The Pioneer Store does not use the homeAddress, but collects the billingAddress and shippingAddress.

These addresses are collected using the value property; for example, the address1 field is collected with the tag: <dsp:input bean="B2CProfileFormHandler.value.billingAddress.address1" type="text" required="<%=true%>"/>

The following fields are collected for each address (some are marked as required in the input tag):

Address Field

Collected?

Required?

firstName

no

yes*

middleName

no

yes*

lastName

no

yes*

address1

yes

yes

address2

yes

no

city

yes

yes

state

yes

no

postalCode

yes

yes

country

yes

yes

telephone

sometimes

no

*These three fields are copied from the user’s profile when the address is created during registration. They can be modified later when the user edits the billing or shipping address. (The telephone is collected for the billing address, but not for the shipping address.)

Customized Registration

The value property of the ProfileFormHandler, defined as a java.util.Map, collects registration data. The B2CProfileFormHandler class adds a second map, editValue, which stores customized profiling fields. This map holds data addresses that go into the property secondaryAddresses. That property is a map, which requires all values to be stored with a key. The key into seondaryAddresses is the “nickname” which the user enters, so the form handler takes the editValue from the form, creates an address from it, and stores it under the nickname provided by the user.

We used the handleCreateUser() method in the ProfileFormHandler class to create a new user. It invokes two other methods. Before doing anything, it invokes preCreateUser(); before exiting, it invokes postCreateUser(). Both these methods can be extended to provide additional functionality.

The B2CProfileFormHandler class defines a preCreateUser() method that copies the firstName, middleName, and lastName fields in the user profile to the billing and shipping addresses, so that the user only has to enter them once during the registration process. The user can modify these addresses to use a different name.

The addressProperties property of the B2CprofileFormHandler defines the address properties that are to be copied. This value may be configured in the properties file, and defaults to:

firstName, middleName, lastName,
address1, address2
city, state, postalCode,
country, ownerId

The B2CProfileFormHandler class also defines a postCreateUser() method that:

 
loading table of contents...