+ Start a Discussion
Emily soaresEmily soares 

Selected picklist value not passed back to Custom controller

Hi,

I have a page listing all applications per job. the application object has a picklist field called ApplicationStatus__c.
We need to be able to select an applicationStatus for each of the applications and save it.
For some reason the selected value from the picklist is not being passed back to the controller.  and the value returned is the initial one ('New').  

public with sharing class JobCandidateController {

    public List <application__c> ListOfApplication {get; set;}
    public List<WrapperApplications> ApplicationWrappersList {get;set;}
   public List <WrapperApplications> ListOfApplicationWrapper {get; set;}

    
    
    private final candidate__c Cand;
    
    public string selectedValue { get; set; }
     
   
    
   
    public JobCandidateController() {       
        
       
       ListOfApplicationWrapper = new List<WrapperApplications>();
       ListOfApplicationWrapper = GetCandidateList();    
        
      
         system.debug ('******Selected VAlues are************ '+ ListOfApplicationWrapper);
       
             
        
    }

    public List <WrapperApplications> GetCandidateList() {
    
   
       
    ApplicationWrappersList = new List <WrapperApplications>();
      
      
      ListOfApplication  = [select candidate__r.Firstname__c,candidate__r.Surname__c, ApplicationStatus__c from application__c  where jobs__c
                   = :ApexPages.currentPage().getParameters().get('id')];
                   
           for (application__c appl : ListOfApplication)
           
           {
           ApplicationWrappersList.add(new WrapperApplications(appl, getOptions() ,'New'));
           
           }
               
                   
              return ApplicationWrappersList;
    }
    
    
   

public List <selectoption> getOptions()
{

    
    Schema.DescribeFieldResult statusFieldDescription = Application__c.ApplicationStatus__c.getDescribe();  
        
   
    
    List<SelectOption> options = new List<SelectOption>();

    
    for (Schema.Picklistentry picklistEntry : statusFieldDescription.getPicklistValues())
    {
        options.add(new SelectOption(pickListEntry.getValue(),pickListEntry.getLabel()));
        system.debug ('******PickList VAlues are************ '+  pickListEntry.getValue());
        
    }
    
    return options;
}
      
      
      //how element are married and displayed on page
      
    public class WrapperApplications {

        public application__c app {get; set;}

        public List < SelectOption > options {get; set;}

        public String selectedValue {get; set;}

      

    public WrapperApplications( application__c c,List < SelectOption > options, String selectedValue) {

     app=c;

     this.options = options;

     this.selectedValue = selectedValue;

     }
   

  }
  
      
      

public PageReference saveCase(){

    List <application__c> ListOfApplicationToUpdate = new List <application__c>();
   
    for(WrapperApplications ca :ListOfApplicationWrapper)
    {
 
    system.debug ('******PickList VAlues are************ '+ ca.selectedValue);
   
    
       ca.app.ApplicationStatus__c = ca.selectedValue;
        //ca.ApplicationStatus__c = selectValue ;
        ListOfApplicationToUpdate.add(ca.app);      

    }
    
    update ListOfApplicationToUpdate;
    return null;
 
}}


<apex:page controller="JobCandidateController"> <apex:pageBlock id="thePageBlock" > <apex:pageBlockTable value="{! ListOfApplicationWrapper}" var="recordCase"> <apex:column > <apex:outputText value="{! recordCase.app.candidate__r.Surname__c }"/> <apex:facet name="header">Candidate FirstName </apex:facet> </apex:column> <apex:column > <apex:outputText value="{! recordCase.app.candidate__r.Firstname__c }"/> <apex:facet name="header">Candidate Surname</apex:facet> </apex:column> <apex:column > <apex:outputText value="{! recordCase.app.ApplicationStatus__c }"/> <apex:facet name="header">Application Status</apex:facet> </apex:column> <apex:column > <apex:form > <apex:selectList size="1" required="true" multiselect="false" label="Type" value="{!recordCase.selectedValue}" onchange="changeStatus()" > <apex:selectOptions value="{!recordCase.options}"/> </apex:selectList> </apex:form> </apex:column> </apex:pageBlockTable> <apex:form > <apex:commandButton value="Save" action="{!saveCase}" /> </apex:form> </apex:pageBlock> </apex:page>
Emily soaresEmily soares
Found the solution to this issue.  
The picklist field and the save button were in two different forms!!!!