1

The code below is running, but there is still a problem... the pick list behaviors is well, but when I saved the record I'm losing the value, so my goal is save the pick list's value in to the custom field Long_Imperial__c, has somebody worked on this?... Can somebody give me a hand???

Controller

public string select_length {get; set;}
public string var_length {get; set;}    
public string var_width {get; set;}

public List<SelectOption> getListWidth() {
    List<SelectOption> options = new List<SelectOption> { new SelectOption('','-- Width --') };
    for(Schema.PicklistEntry gr:Customer_s_Price_List__c.Wide_Imperial__c.getDescribe().getPicklistValues()) {
        options.add(new SelectOption(gr.getValue(),gr.getLabel()));
    }
    return options;
}

public List<SelectOption> getlength(){

    List<SelectOption> options = new List<SelectOption>();

        var_width = cpl.Wide_Imperial__c;

        if(var_width == null)
        return null;{
        if(var_Product_Type =='Laminated / + 10'){
            options.add(new SelectOption('9','9'));
            options.add(new SelectOption('18','18'));
        }
        if( var_Product_Type =='Plasma' && (var_width =='1/4' || var_width =='3/8' ) ){
            options.add(new SelectOption('9','9'));
            options.add(new SelectOption('18','18'));
        }
        if( var_Product_Type =='Plasma' && !(var_width =='1/4' || var_width =='3/8' )){
            options.add(new SelectOption('9','9'));
            options.add(new SelectOption('36','36'));
        }
    }
    return options;
}

Visualforce

<apex:pageBlockSection title="Imperial System" columns="1" rendered="
{!Customer_s_Price_List__c.System_Of_Measurement__c == 'Imperial System'}">
<apex:inputField value="{!Customer_s_Price_List__c.Wide_Imperial__c}"> 
<apex:actionSupport event="onchange" reRender="size"/>
</apex:inputField>
<apex:outputPanel id="size">
<apex:pageBlockSection columns="1">
<apex:pageBlockSectionItem >
<apex:outputLabel style="margin:16px;">Length (Yards)</apex:outputLabel>
<apex:selectList size="1" style="margin-left:-16px;" value="{!select_length}">
<apex:selectOptions value="{!length}"/>
</apex:selectList>
</apex:pageBlockSectionItem>
0

try adding/merging following code lines into your code.

/*****Controller*****/
    Customer_s_Price_List__c obj;

    public myControllerExtension(ApexPages.StandardController stdController) {
        this.obj = (Customer_s_Price_List__c)stdController.getRecord();
    }

    public pageReference customSave(){
        obj.Long_Imperial__c = select_length;
        insert obj;
        OR
        update obj;
    }

/*****Page*****/
    <apex:inputHidden value="{!Customer_s_Price_List__c.Long_Imperial__c}"/>

Hope this may help.

0

Finally, for everyone who is stacked with the same problem!!!

I resolved this issue changing:

apex:selectList size="1" style="margin-left:-16px;" value="{!select_length}"

by this line,

apex:selectList size="1" style="margin-left:-16px;" value="{!Customer_s_Price_List__c.Long_Imperial__c}"

Now it's working perfect!!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.