function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Trouble persisting Multiselect Picklist when page has validation errors upon save

Dear experts,
I've implemented Pat Patterson's Multiselect Picklist in my visualforce page using the example from:

But I have found an issue which I am having difficulty resolving. Upon saving the visualforce page, if there is a validation error, then the values that were selected on the right options list disappears and the changes are lost. The actual record is not saved, but I still wanted the values to persist even if a refresh is caused by the validation error.
My understanding is that the save() action loops through the values in the rightOptions list to build a list of select options to insert, but because the validation error happens even before the save action is called, the data is not persisted.

For example, in the code below, any changes made to the allContacts and selectedContacts do not get persisted when the page is refreshed as a result of a validation error:
<c:MultiselectPicklist leftLabel="Available Contacts"
    rightLabel="Selected Contacts"
Is there a workaround to still build the right options list during the validation stage?

Look forward to your answers. Thanks in advance!