Repopulating the selectList

In order to properly repopulate the Visualforce selectList, you can add AJAX functionality to your page, which is implemented automatically without having to write any Javascript code, whenever the user has changed the value in the Department list.

As you learned in Chapter 9, this interactive capability is easy to use with Visualforce.

1.
Add the highlighted code to your Visualforce page.
</apex:pageBlocksection>
     <apex:actionRegion >
         <apex:pageblocksection columns="1"
           title="Department">
            <apex:inputField
              value="{!Position__c.Department__c}"/>
            <apex:actionSupport event="onchange"
								rerender="dependentPositionType"
								status="departmentStatus"/>
								<apex:actionStatus id="departmentStatus"
								startText="Fetching position types..."/> ...

Get The Developer’s Guide to the Force.com Platform now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.