I am trying to create a custom dependent picklist in Visualforce (I cannot use the standard field tags because the guest site user does not have access to the User object). I am using the selectOption tag as well as actionSupport to reference my method in a custom controller and I am stuck. I made sure there is a default value in the primary picklist. I've searched the boards and tried to make sure my actionSupport is correct. I also put the entire thing within the apex:actionRegion tag and that did not help. I had my developer friend take a look and he could not fix it either. The error I am getting is that I view the page, enter data and select an option within the first list. I then get an error that the apex action method must be a page reference. I don't actually know what that means or how to fix it. Here is my controller (at least the relevant part). VF page below.
public with sharing class CommunitiesSelfRegController {
/*** An apex page controller that supports self registration of users in communities that allow self registration */
public String firstName {get; set;}
public String lastName {get; set;}
public String email {get; set;}
public String phone {get; set;}
public String password {get; set {password = value == null ? value : value.trim(); } }
public String confirmPassword {get; set { confirmPassword = value == null ? value : value.trim(); } }
public String communityNickname {get; set { communityNickname = value == null ? value : value.trim(); } }
public String location {get; set{location = value;}}
public List<SelectOption> customerOrgs{get;set;}
public String selectedCustomerOrg {get; set;}
public CommunitiesSelfRegController() {
location='108 Charter Oak';
getCustomerOrgs();
}
public void setCustomerOrgs(List<SelectOption> orgs) {
this.customerOrgs = orgs;
}
public List<SelectOption> getCustomerOrgs(){
List<SelectOption> locs= new List<SelectOption>();
if(location==null)
return null;
else
{
if(location.contains('Aerospace Elementary School')){
locs.add(new SelectOption('Aerospace Elementary School','Aerospace Elementary School'));
locs.add(new SelectOption('Other','Other'));
}
if(location.contains('108 Charter Oak')){
locs.add(new SelectOption('Student Services', 'Student Services'));
locs.add(new SelectOption('Other','Other'));
}
if(location.contains('147 Charter Oak')){
locs.add(new SelectOption('Business Services','Business Services'));
locs.add(new SelectOption('Facilities','Facilities'));
locs.add(new SelectOption('Food Services','Food Services'));
locs.add(new SelectOption('Human Resources','Human Resources'));
locs.add(new SelectOption('Operations','Operations'));
locs.add(new SelectOption('Other','Other'));
}
if(location.contains('155 Wyllys Street')){
locs.add(new SelectOption('CREC Transporation','CREC Transporation'));
locs.add(new SelectOption('Other','Other'));
}
}
return locs;
}
` Visualforce page (just the relevant part):
<apex:outputLabel value="Location" for="Location"/> <apex:actionRegion> <apex:outputPanel id="one"> <apex:selectList value="{!location}" title="Location" multiselect="false" size="3" onchange="{!Location}"> <apex:selectOption itemValue="Aerospace Elementary School" itemLabel="Aerospace Elementary School"/> <apex:selectOption itemValue="108 Charter Oak" itemLabel="108 Charter Oak"/> <apex:selectOption itemValue="147 Charter Oak" itemlabel="147 Charter Oak"/> <apex:selectOption itemvalue="155 Wyllys Street" itemLabel="155 Wyllys Street"/> <apex:actionSupport event="onchange" action="{!getcustomerOrgs}" reRender="two"/> </apex:selectList> <br/> <apex:outputPanel >Location: {!location}</apex:outputPanel> <br/> <apex:outputPanel id="two"> <b>Choose a Customer Organization</b> <apex:selectList size="1" value="{!customerOrgs}"> <apex:selectOptions value="{!CustomerOrgs}"/> </apex:selectList> </apex:outputPanel> </apex:outputPanel> </apex:actionRegion>