You need to sign in to do that
Don't have an account?
Justin Denning
Rerender clearing values?
I have a dropdown list of regions that seems to be clearing all values in my controller, and I don't know what I'm doing wrong. Below is the controller and VF page along with 2 pictures- one showing values loading on the initial page load, and showing no values when the Region dropdown is changed.
Any help is greatly appreciated.
Page after changing the dropdown- RegionId and SelectOptions are cleared
Any help is greatly appreciated.
Page after changing the dropdown- RegionId and SelectOptions are cleared
public with sharing class RegionController { public static Id RegionId {get;set;} public static Map<Id, Region__c> Regions {get;set;} public static List<SelectOption> regionOptions {get;set;} public RegionController { //Default Id for testing RegionId = 'a0KA0000001IUO0MAO'; //Get Map of regions Regions = new Map<Id, Region__c>([SELECT ID, Name FROM Region__c]); //Set Region Options SelectOption sO; regionOptions = new List<SelectOption>(); for (Id i : Regions.keySet()) { sO = new SelectOption(i, Regions.get(i).Name); regionOptions.add(sO); } } public PageReference DoNothing() { return null; } }
<apex:page showHeader="true" controller="RegionController" sidebar="true"> <apex:form> <apex:selectList size="1" value="{!RegionId}" > <apex:actionSupport event="onchange" action="{!DoNothing}" rerender="RegionPanel" /> <apex:selectOptions value="{!regionOptions}"/> </apex:selectList> </apex:form> <apex:outputPanel id="RegionPanel" > Region {!RegionId}<br/> Options <br/> <apex:repeat value="{!RegionOptions}" var="regions"> {!regions}<br/> </apex:repeat> </apex:outputPanel> </apex:page>
All Answers