You need to sign in to do that
Don't have an account?
Mary Pustejovsky
dependent picklist in Visualforce not re-rendering
Hello
I am somewhat new to VF/Apex and I've created a dependent picklist to use in Visualforce. Everything saves fine. When I go to preview, the first picklist appears correctly but the second one does not re-render once the first option is chosen. I am not sure what I am doing wrong. I have searched many boards/blogs etc and tried a couple different things. Any advice would be greatly appreciated. There are actually tons more options in my lists but I figured no one needed to see all of those to understand the issue.
Here is the VF:
Here is the controller (at least the relevant part):
I am somewhat new to VF/Apex and I've created a dependent picklist to use in Visualforce. Everything saves fine. When I go to preview, the first picklist appears correctly but the second one does not re-render once the first option is chosen. I am not sure what I am doing wrong. I have searched many boards/blogs etc and tried a couple different things. Any advice would be greatly appreciated. There are actually tons more options in my lists but I figured no one needed to see all of those to understand the issue.
Here is the VF:
<apex:page id="communitiesSelfRegPage" showHeader="true" controller="CommunitiesSelfRegController" title="{!$Label.site.user_registration}"> <apex:define name="body"> <center> <apex:form id="theForm" forceSSL="true"> <apex:pageMessages id="error"/> <apex:panelGrid columns="2" style="margin-top:1em;"> <apex:outputLabel value="First Name" for="firstName"/> <apex:inputText required="true" id="firstName" value="{!firstName}" label="First Name"/> <apex:outputLabel value="Last Name" for="lastName"/> <apex:inputText required="true" id="lastName" value="{!lastName}" label="Last Name"/> <apex:outputLabel value="{!$Label.site.community_nickname}" for="communityNickname"/> <apex:inputText required="true" id="communityNickname" value="{!communityNickname}" label="{!$Label.site.community_nickname}"/> <apex:outputLabel value="{!$Label.site.email}" for="email"/> <apex:inputText required="true" id="email" value="{!email}" label="{!$Label.site.email}"/> <apex:outputLabel value="Location" for="Location"/> <apex:selectList value="{!location}" title="Location" multiselect="false" size="3" > <apex:selectOption itemValue="Aerospace Elementary" itemLabel="Aerospace Elementary School"/> <apex:selectOption itemValue="108 Charter Oak" itemLabel="108 Charter Oak"/> <apex:actionSupport event="onchange" reRender="one"/> </apex:selectList> <br/> <apex:outputPanel id="one"> <b>Choose a Customer Organization</b> <apex:selectList size="1" value="{!customerOrganization}"> <apex:selectOptions value="{!customerOrganization}"/> </apex:selectList> </apex:outputPanel> <apex:outputLabel value="{!$Label.site.password}" for="password"/> <apex:inputSecret id="password" value="{!password}"/> <apex:outputLabel value="{!$Label.site.confirm_password}" for="confirmPassword"/> <apex:inputSecret id="confirmPassword" value="{!confirmPassword}"/> <apex:outputText value=""/> <apex:commandButton action="{!registerUser}" value="{!$Label.site.submit}" id="submit"/> </apex:panelGrid> <br/> </apex:form> </center> <br/> </apex:define> </apex:page>
Here is the controller (at least the relevant part):
public with sharing class CommunitiesSelfRegController { 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;} public String customerOrganization{get;set;} public CommunitiesSelfRegController() {} public List<SelectOption> getCustomerOrg(){ 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')); } } return locs; }
@Mary Pustejovsky:
Couple of things.,
Change your constructor to this:
and the get method to:
Reason is "Aerospace Elementary" is the value you chosen for the label "Aerospace Elementary School" and you need to compare the Values not the labels.
Hope it helps.,
Thanks,
Balaji
Thanks for the note. I updated the constructor and the method and it still does not work. Other ideas anyone?
Make sure you are populating all the required fields on the page before testing.
Action support will not work if there are any validation errors on the page
Regards,
Bhanu Mahesh