+ Start a Discussion

SelectList Value returns null

I'm am developing a visualforce page to take an original set of records (representing field mappings) and allow the user to change them using 'SelectLists'/'SelectOptions' and save them to new records. However, when I debug the page, I find that any 'SelectList' value that is changed using the drop-down on the page is null when I go to 'save()' the new records:



public List<MeetingFieldMappings1__c> fieldMappings {get; set;}
public void setupFieldMapping(){ 
		// get the current field mappings
		List<MeetingFieldMappings1__c> mappings = new List<MeetingFieldMappings1__c>();
		if(meeting != null){
			mappings = [SELECT Id,Name,LeadField__c,ContactField__c,LeadAllowUpdates__c,ContactAllowUpdates__c,Meeting__c 
							FROM MeetingFieldMappings1__c WHERE Meeting__c = :meeting.id LIMIT 25];
				if(mappings.size() > 0){			
					mappingsExist = true;
					fieldMappings = mappings;
			// defaults
			mappingsExist = false;
			mappings = [SELECT Id,Name,LeadField__c,ContactField__c,LeadAllowUpdates__c,ContactAllowUpdates__c,Meeting__c 
								FROM MeetingFieldMappings1__c WHERE Meeting__c = null LIMIT 25];
			fieldMappings = mappings;



	<div id="fieldMappingDialog" style="display: none;">
	<apex:pageBlock >
			    <th>Meeting Member Field</th>
			    <th>Lead Field</th>
			    <th>Contact Field</th>
           	<apex:repeat value="{!fieldMappings}" var="mapping">
			    <td><apex:outputField value="{!mapping.Name}" /></td>
		    	<apex:selectList value="{!mapping.LeadField__c}" size="1" disabled="{!NOT(mapping.LeadAllowUpdates__c)}">
			            <apex:selectOptions value="{!leadFieldsPickList}" />
			    	<apex:selectList value="{!mapping.ContactField__c}" size="1" disabled="{!NOT(mapping.ContactAllowUpdates__c)}">
			            <apex:selectOptions value="{!contactFieldsPickList}" />

 What am I doing wrong?

JHayes SDJHayes SD

What does the controller code look like for leadFieldsPickList and contactFieldsPickList?

   public List<selectOption> contactFieldsPickList { get{
      SObject s = new Contact();
      List<selectOption> options = new List<selectOption>(); //new list for holding all of the picklist options
      //blank options
      options.add(new selectOption('','--'));
      Schema.sObjectType sobject_type = s.getSObjectType(); //grab the sobject that was passed
      Schema.DescribeSObjectResult sobject_describe = sobject_type.getDescribe(); //describe the sobject
      Map<String, Schema.SObjectField> field_map = sobject_describe.fields.getMap(); //get a map of fields for the passed sobject

      // sort the list from the fieldset name
      Set<string> listOfNames = field_map.keySet();
      List<string> sortedListOfNames = new List<string>();
      for (String fieldName : sortedListOfNames){
      	Schema.DescribeFieldResult F = field_map.get(fieldName).getDescribe();
        options.add(new selectOption(fieldName,F.getLabel()));
      return options; //return the List
   } set;}

 Here is an example of the picklist values generator.


Sorry the first set of code is such a klug, it's hard to read. I've actually made a test page using the same code without any of the other elements on the page and it worked fine. 


So I'm thinking it's another issue rather than I'm not creating the picklists correctly!


The issue seems to be: I am using a jQuery.dialog({}); function in jQuery UI and it is screwing up the form! I think I'll have to create a 2nd form and have it mirror the values in the dialog if i want this UI affect.