+ Start a Discussion
Mike @ BlackTabMike @ BlackTab 

Rerendering apex:selectList components

Background: I have three apex:selectLists that are dependent on one another. When a value is choosen in the first picklist, options in the other picklists become available. 

 

The problem: These picklists were working fine when nested inside an apex:pageBlockSection, however when I moved the code to a jQuery controlled div the values from the select lists are no longer passed to the controller. Any ideas?

 

VF:

 

<apex:selectlist value="{!projectID}" multiselect="false" size="1" style="margin-right: 5px;">
              <apex:selectOption itemvalue="" itemLabel="--Open Projects--" />
              <apex:selectoptions value="{!openProjects}"/>
              <apex:actionsupport event="onchange" rerender="milestoneList"/>
          </apex:selectlist>
          <apex:selectlist value="{!milestoneID}" multiselect="false" size="1" id="milestoneList" style="margin-right: 5px;">
              <apex:selectOption itemvalue="" itemLabel="--Milestones--" />
              <apex:selectoptions value="{!RelatedMilestones}"/>
              <apex:actionsupport event="onchange" rerender="deliverableList"/>
          </apex:selectlist>
          <apex:selectlist value="{!deliverableID}" multiselect="false" size="1" id="deliverableList">
              <apex:selectOption itemvalue="" itemLabel="--Deliverables--" />
              <apex:selectoptions value="{!RelatedDeliverabiles}"/>
          </apex:selectlist>

 Controller:

 

public String projectID {get; set;}
public String milestoneID {get; set;}
public String deliverableID {get; set;}

//Populate the "Related To" Project Picklist
    public List<SelectOption> getOpenProjects() {
        List<SelectOption> options = new List<SelectOption>();
        List<Project2__c> projects = [SELECT Name, ID FROM Project2__c 
                                      WHERE Status__c != 'Completed' 
                                      ORDER BY Name];
        
        for(Project2__c p : projects){
            options.add(new SelectOption(p.ID, p.Name));
        }
        
        return options;
    }
    
    //Populate the "Related To" Milestones Picklist
    public List<SelectOption> getRelatedMilestones() {
        List<SelectOption> options = new List<SelectOption>();
        List<Milestone_NEW__c> milestones = [SELECT Name, ID FROM Milestone_NEW__c 
                                             WHERE Project__c = :projectID 
                                             ORDER BY Name];
        
        for(Milestone_NEW__c m : milestones){
            options.add(new SelectOption(m.ID, m.Name));
        }
        
        return options;
    }
    
    //Populate the "Related To" Deliverablies Picklist
    public List<SelectOption> getRelatedDeliverabiles() {
        List<SelectOption> options = new List<SelectOption>();
        List<Deliverable__c> deliverables = [SELECT Name, ID FROM Deliverable__c 
                                             WHERE Milestone_NEW__c = :milestoneID 
                                             ORDER BY Name];
        
        for(Deliverable__c d : deliverables){
            options.add(new SelectOption(d.ID, d.Name));
        }
        
        return options;
    }

 

AravindBabu512AravindBabu512

Hi Mike,

 

Try having the dependent picklists as output panel, this must work.

 

Thanks,

Aravind

Mike @ BlackTabMike @ BlackTab

Still nothing. I wrapped the picklists in an apex:outputPanel and gave it an id, but nothing is happening. Should I rerender the entire output panel rather then the subsequent picklists?

Mike @ BlackTabMike @ BlackTab

When I tell it to rerender the entire outputPanel, it sets the picklist back to the first value when the page redraws.

AravindBabu512AravindBabu512

I guess that should be the expected behavior right. Based on the Project the milestones and deliveries should change. I had a similar requirement where i had Year, Make and Model picklists and based on Year, I need to load Make and based on Make i need to load Model. For this i had used Output panel and rerendered the entire panel.

 

Thanks,

Aravind

Uzair Ahmadani 4Uzair Ahmadani 4
place the dependent select list in there subsequent output panel and instead of rendering the select list rerender the output panel and see if it works