By default, the RepositoryFormHandler
updates a property value by overwriting its old value with the new one. In the case of multi-valued properties, you can modulate this behavior in the following ways:
Add the form values to the current property values; or use the form values to remove any current property values that match.
Specify the maximum number of values to add, update, or remove.
Note: These property options are available only if the extractDefaultValuesFromItem
property is set to true.
updateMode
The form handler property updateMode
specifies how changes to a property value affect existing data. You can set updateMode
to one of these values:
append
appends the new form values to the current ones.prepend
prepends the new form values to the current ones.replace
(the default behavior) overwrites old values with new valuesremove
removes any existing values that match the selected form values.
For example, the list property hobbies
has the following string values:
Mountain Biking
Running
Canoeing
The form contains a hidden input tag that sets the update mode for the hobbies property with the following format:
<dsp:input type="hidden" bean="myHandler.value.hobbies.updateMode" value="update
-
mode
"/>
The following table shows the various values for update
-
mode
and how various input scenarios set the property’s value:
updateMode value | User input | Resulting property value |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
numNewValues
If updateMode
is set to prepend
or append
, you must also set numNewValues
to a positive integer. By default, it is set to 0
. The following code example specifies to append a gift list to the list property giftlists
:
Enter Gift list: <dsp:input type="text" bean="MyRepositoryFormHandler.value.giftlists"/> <dsp:input type="hidden" bean="MyRepositoryFormHandler.value.giftlists.updateMode" value="append"/> <dsp:input type="hidden" bean="MyRepositoryFormHandler.value.giftlists.numNewValues" value="1"/>