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 updateMode
property 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.
Note: If updateMode
is set to append
or prepend
, you must also set the numNewValues attribute.
For example, the list property hobbies
has the following string values:
Mountain Biking
Running
Canoeing
The form contains an input tag for the hobbies
property whose update mode is specified with the following format:
<dsp:input 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:
updateModevalue | Userinput | Resultingpropertyvalue |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
numNewValues
If updateMode
is set to prepend
or append
, you must also set numNewValues
to a positive integer, to indicate the number of items to add.
For example, the following code specifies to add a single 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"/>