The following example shows how to create multiple user profiles. In a real-life application, a preceding page contains the user count and that value is passed as a parameter to this page and set according by the <dsp:setvalue> function.

<%@ taglib uri="http://www.atg.com/taglibs/daf/dspjspTaglib1_0" prefix="dsp" %>

<dsp:page>
<HTML>
<HEAD>
<TITLE>Create Multiple Profile Forms</TITLE>
</HEAD>

<dsp:importbean bean="/atg/userprofiling/MultiProfileAddFormHandler"/>
<dsp:importbean bean="/atg/dynamo/droplet/ForEach"/>

<%-- The next line sets the form handler's count property to the number of users
to be added by this form. For demonstration purposes, the count value has been
hard-coded here. In reality, a preceding page would specify the user count and
pass it as a parameter to this page to be set accordingly using <dsp:setvalue
value="null"/>. --%>

<dsp:setvalue bean="MultiProfileAddFormHandler.count" value="2"/>

<BODY>

<%-- The next line sets the action page for this form to be the same
as the current page --%>
<dsp:form action="MultiProfileAdd.jsp" method="post">

<%-- The following hidden input tag makes sure that the count value is set and
carried over for a request scoped (the default) form handler. Placing it at the
beginning of the form ensures it will be set before the get is done on the users
array property which is where the allocation of the array is done --%>

<dsp:input bean="MultiProfileAddFormHandler.count" type="hidden"/>

<%-- The next two lines set the form redirection locations for success or failure.
--%>
<dsp:input bean="MultiProfileAddFormHandler.createSuccessURL" type="hidden"
value="MultiProfileUpdate.jsp"/>
<dsp:input bean="MultiProfileAddFormHandler.createErrorURL" type="hidden"
value="myAdderror.jsp"/>

<%-- The next two lines initialize the setting of a default password to be used
for each user created by this form. --%>
<dsp:input bean="MultiProfileAddFormHandler.generatePassword" type="hidden"
value="true"/>
<dsp:input bean="MultiProfileAddFormHandler.defaultPassword" type="hidden"
value="test"/>

<h3>Update per-user contact information:</h3>

<%-- Using a ForEach droplet, display the input tags for each per-user property to
be set by this form --%>
<dsp:droplet name="/atg/dynamo/droplet/ForEach">
<%-- Set the array parameter to the list of users to be added so that the
properties set will end up in the value Dictionary for the associated user. --%>
  <dsp:param bean="MultiProfileAddFormHandler.users" name="array"/>
  <dsp:oparam name="output">
      <UL>
      User: <dsp:valueof param="count"/>
      </UL>
        <table width=456 border=0>
  <tr>
    <%-- The following lines create the actual fields displayed on the form for
each profile being added. They are placed in a table here and repeated for the
number of users requested by this form. --%>
    <td valign=middle align=right>Login Name:</td>
    <td><dsp:input
bean="MultiProfileAddFormHandler.users[param:index].value.login" maxsize="30"
size="30" type="text"/></td>
  </tr>
  <tr>
    <td valign=middle align=right>First Name:</td>
    <td><dsp:input
bean="MultiProfileAddFormHandler.users[param:index].value.firstName" maxsize="30"
size="30" type="text"/></td>
  </tr>
  <tr>
    <td valign=middle align=right>Last Name:</td>
    <td><dsp:input
bean="MultiProfileAddFormHandler.users[param:index].value.lastName" maxsize="30"
size="30" type="text"/></td>
  </tr>
  <tr>
    <td valign=middle align=right>Email:</td>
    <td><dsp:input
bean="MultiProfileAddFormHandler.users[param:index].value.email" maxsize="30"
size="30" type="text"/></td>
  </tr>
  <tr>
    <td valign=middle align=right>Aggresive Index:</td>
    <td><dsp:input
bean="MultiProfileAddFormHandler.users[param:index].value.aggressiveIndex"
maxsize="30" size="30" type="text"/></td>
  </tr>
</table>
  </dsp:oparam>
  <dsp:oparam name="empty">
    array is empty!
  </dsp:oparam>
</dsp:droplet>

<%-- The next section of lines contain the input tags for the property values that
are shared by all the users being added by this form. Notice they are assigned to
the "value" Dictionary in the same way as in using the ProfileFormHandler. --%>
<h3>Update common properties:</h3>
<table width=456 border=0>
<tr>
<td valign=middle align=right>Locale:</td>
<td><dsp:input bean="MultiProfileAddFormHandler.value.locale" maxsize="30"
size="30" type="text"/></td>
</tr>
<tr>
<td valign=middle align=right>Member (true/false):</td>
<td><dsp:input bean="MultiProfileAddFormHandler.value.member" maxsize="30"
size="30" type="text"/></td>
</tr>
<tr>
<td valign=middle align=right>User Type (investor/broker/guest):</td>
<td><dsp:input bean="MultiProfileAddFormHandler.value.userType" maxsize="30"
size="30" type="text"/></td>
</tr>
</table>

<%-- Display two different submit options - create and cancel which invoke methods
in the Form Handler --%>
<dsp:input bean="MultiProfileAddFormHandler.create" type="submit" value="save"/>
<dsp:input bean="MultiProfileAddFormHandler.cancel" type="submit" value="cancel"/>
</dsp:form>
</BODY>
</HTML>
</dsp:page>
 
loading table of contents...