Force.com Epiphanies

In order to display a multi-select picklist on the page from a list of values we can re-use, we create a generic component called ‘MultiSelect’ and reference it in our visualforce page.   This example gets values from a custom setting list.

Component: <apex:component controller="MultiSelectComponentController"> <apex:attribute name="AvailableList" type="selectOption[]" description="Available List from the Page" assignTo="{!options}" required="True"/> <apex:attribute name="ChosenList" type="selectOption[]" description="Chosen List from the Page" assignTo="{!selectedOptions}" required="True"/> <!-- <apex:attribute name="AvailableTitle" type="String" description="Title for Available List" assignTo="{!selectedTitle}"/> --> <!-- <apex:attribute name="ChosenTitle" type="String" description="Title for Chosen List" assignTo="{!deSelectedTitle}"/> --> <apex:outputPanel id="panel"> <apex:pageBlockSection columns="4" > <apex:selectList multiselect="true" size="5" value="{!selected}" > <apex:selectOptions value="{!options}" /> <apex:actionSupport event="ondblclick" action="{!selecting}" rerender="panel" status="waitingStatus" /> </apex:selectList> <apex:pageBlockSection columns="1"> <!-- <apex:outputText value="{!selectedTitle}" /> --> <apex:commandButton reRender="panel" id="select" action="{!selecting}" value=">" status="waitingStatus"/> <!-- <apex:outputText value="{!delectedTitle}" /> --> <apex:commandButton reRender="panel" id="deselect" action="{!deselecting}" value="<" status="waitingStatus"/> </apex:pageBlockSection> <!-- An action status to show that the operation of moving between the lists is in progress---> <apex:actionStatus id="waitingStatus" startText="Please wait..."…

View original post 154 more words