8

Pat Patterson's Multiselect Picklist component is exactly what I need for a page I am working on, and works great with API version 26. However, when I try to use it with a more current API version (anything above v 27), attempts to save the MultiselectPicklist Component file throw the following error:

<apex:attribute assignTo> cannot be same as the <apex:attribute name> ( leftOptions )   

I understand that this is a security feature (see Spring '13 VF Component Issue ), however after messing with the getter and setter methods I am unable to get the file to work as expected with a current API version.

Is there a standard approach to update older code with this problem to work with the new API?

The file's source is available to view on GitHub; an example of the problematic lines are 26-28.

Thanks!

  • 1
    In theory, it would be a case of renaming either the name or the assignTo to be different, probably changing the name (e.g. leftOptionsIn instead of leftOptions) would be easier then change your VF page that refers to that. – Phil Hawthorn Dec 18 '13 at 14:18
  • Can what ever working update comes out of this also be made into a pull request on github - that'd be great. – Samuel De Rycke Dec 18 '13 at 14:22
7
<apex:attribute name="leftOptions"
description="Options list for left listbox." type="SelectOption[]"
required="true" assignTo="{!leftOptions}" />
 <apex:attribute name="rightOptions"
description="Options list for right listbox." type="SelectOption[]"
required="true" assignTo="{!rightOptions}" />

The above code can be changed as below

 <apex:attribute name="leftOption"
description="Options list for left listbox." type="SelectOption[]"
required="true" assignTo="{!leftOptions}" />
 <apex:attribute name="rightOption"
description="Options list for right listbox." type="SelectOption[]"
required="true" assignTo="{!rightOptions}" />

And in the page we can have as below

<apex:page controller="MultiselectExampleController">
<apex:form >
    <apex:pageBlock title="Contacts">
        <c:MultiselectPicklist leftLabel="Available Contacts"
            leftOption="{!allContacts}"
            rightLabel="Selected Contacts"
            rightOption="{!selectedContacts}"
            size="14"
            width="150px"/>
        <apex:pageBlockButtons >
            <apex:commandButton value="Save" action="{!save}"/>
        </apex:pageBlockButtons>
    </apex:pageBlock>
</apex:form>
<apex:outputText >{!message}</apex:outputText>

Simply changing the name of attributes will solve the problem .

| improve this answer | |
  • That seems to have done the trick! Thank you Mohith. Such a simple fix, but I was thinking about it the wrong way (changing the class rather than the VF page). I will submit a pull request as Sdry suggested. – Rob Dec 18 '13 at 14:48
  • Glad that it helped :).I will see if i can pull request and update the code .Thanks – Mohith Shrivastava Dec 18 '13 at 14:49
  • @MohithKumar Could you resubmit the change as a single pull request? Kind of confusing to have one request per file. – metadaddy Dec 19 '13 at 21:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.