In order to facilitate updates to multi-valued profile properties, the ProfileFormHandler provides the addMulti operation. This operation appends a new value to a multi-valued property in the ProfileFormHandler's value Dictionary. addMulti can add multiple primitive values to types array, set and list. The addMulti feature cannot handle multiple Map type values, or multiple items, as opposed to primitive data. To add multiple items, you must write your own form handler, as described in the Working with Forms and Form Handlers chapter of the Platform Programming Guide.
Unlike the other ProfileFormHandler operations, addMulti does not update the user profile when its submit button is clicked. Instead, it appends the entered value to the value Dictionary. Thus, the form user can add multiple values to the property before submitting them. Therefore, a page that implements an addMulti submit button must also provide a submit button that creates or updates the user profile.
The following code shows how a form might contain an addMulti operation:
<dsp:select multiple="true" bean="ProfileFormHandler.value.interests" name="interests" size="4"> <dsp:droplet name="ForEach"> <dsp:param bean="ProfileFormHandler.value.interests" name="array"/> <dsp:oparam name="output"> <dsp:option paramvalue="element" selected="true"/><dsp:valueof param="element">null</dsp:valueof> </dsp:oparam> </dsp:droplet> </dsp:select> <dsp:input name="Add Interests" type="hidden" value="AddMultiProperty_interests, AddMultiValue_interests"/> <dsp:input name="AddMultiProperty_interests" type="hidden" value="interests"/> <dsp:input name="AddMultiValue_interests" type="text"/> <dsp:input bean="ProfileFormHandler.addMulti" name="addMultiProperty" type="submit" value="Add Interests">
This code example contains the following steps:
The dsp:select tag specifies how many values for the
interestsfield are available in the form.The ForEach servlet bean iterates through the array of Strings specified in the
bean.ProfileFormHandler.value.interestsparameter. If an interest is selected, it outputs the value; otherwise, it outputs null as the interest element value.A hidden input tag defines two text strings; these strings link the next two subsequent input tags:
AddMultiProperty_interestsis referenced by a hidden input tag’snameattribute; this input tag’svalueattribute identifies the target Dictionary property.AddMultiValue_interestsis referenced by the text input tag’snameattribute. Form users use this field to enter new values for the target property.
The tag’s
nameattribute is set toAdd Interests; this links the Dictionary property and text input field with theaddMultisubmit button.The tag that defines the
addMultisubmit button must set itsnameandvalueattributes as follows:namemust be set toaddMultiPropertyvaluemust be set toAdd Interests
Note: In order to enable addMulti operations for several multi-valued properties on the same page, each property must have its own pair of unique identifiers as described above, and a unique string for its submit button’s value attribute.

