function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Binding Custom Component with Sobject field, failed to save

I have custom component which combined to dropdown list, and I did binding to custom object fields, no issue to get the value from object, but can not save the change..need helps.


custom component clss

public with sharing class cComponetCombinedList {
  public string basecolorvalue {get;set;} 
  public string stripecolorvalue {get;set;}
  private list<SelectOption> items;
  public list<SelectOption> getItems(){
    List<SelectOption> items = new List<SelectOption>();
    items.add(new SelectOption('','--None--'));
    items.add(new SelectOption('BG','BG'));
    items.add(new SelectOption('BK','BK'));
    items.add(new SelectOption('BU','BU'));
    items.add(new SelectOption('BU (LT BL)','BU (LT BL)'));
    items.add(new SelectOption('BN','BN'));
    items.add(new SelectOption('DB','DB'));
    items.add(new SelectOption('DG','DG'));
    items.add(new SelectOption('GN','GN'));
    items.add(new SelectOption('GN (LT GN)','GN (LT GN)'));
    items.add(new SelectOption('GY','GY'));
    items.add(new SelectOption('OG','OG'));
    items.add(new SelectOption('PK','PK'));
    items.add(new SelectOption('RD','RD'));
    items.add(new SelectOption('VT','VT'));
    items.add(new SelectOption('WH','WH'));
    items.add(new SelectOption('YE','YE'));
    return items;



Custom Component


<apex:component controller="cComponetCombinedList">
	<apex:attribute name="basecolor" description="the base color of the cable" 
			type="String" required="true" assignTo="{!basecolorvalue}">
	<apex:attribute name="stripecolor" description="the stripe color of the cable" 
			type="String" required="true" assignTo="{!stripecolorvalue}">
	<apex:selectList value="{!basecolorvalue}" size="1">
		<apex:selectOptions value="{!items}">
	<apex:selectList value="{!stripecolorvalue}" size="1">
		<apex:selectOptions value="{!items}">


below is the component referenced in VF:

apex:PageBlockSectionItem >
					<apex:outputLabel value="Pin 1 Base / Stripe Color:"/>
					<c:ComponentCombinedList basecolor="{!SRS_Product_Configuration__c.Pin_1_Base_Color__c}" 


rendered in page correct:




when I change the values and save:



the value still as old:


Any ideas, comments are apperiated. Thanks






Do you update your new value of the record in your save method ? If not , reloading of the page will still display the old value.



When I use standard inputfield component, it is works fine..the save method should not have any issue.


<apex:inputField value="{!SRS_Product_Configuration__c.Pin_1_Base_Color__c}"> </apex:inputField>
<apex:inputField value="{!SRS_Product_Configuration__c.Pin_2_Stripe_Color__c}"> </apex:inputField>



Qingsong, you are passing an SOBjects field to a component attribute and expect a change in the components variable resulting from that attribute to reflect magically in the sobject. This is not going to work.


You can pass the whole SObject into the component but even then you need to update the changes you custom controller does to this field using you visualforce page.


So I can you confirm what the previous post said. Nothing is going to change unless your custom controller manipluates and updates a real SObject or copies the changes to an existing SObject.