+ Start a Discussion
ssssssss 

how to save the dependent pick list values using visual force with apex

Hi All,

 

In my VF page some input fileds and dependent pick lists are there.I am overriding the standard save button.i had created dependent picklists using Vf with apex(using <apex:selectList>).All input fileds are saved but picklist values are not saved.if any one knows tell me the solution.

 

Thanks in advance,

manu..

markdamomarkdamo
Are you connecting the apex select list to an object.  IE <apex:selectlist value="{!contact.name}" >
ssssssss

Thanks for ur reply,

  

yes i am using like that.In my code i am using setters and getters.my code is as follows.

 

VF page code:

 

<apex:selectList value="{!streamid}" size="1" id="optionList">
                 <apex:selectOptions value="{!streamval}"></apex:selectOptions>
                 <apex:actionSupport event="onchange" reRender="Course" action="{!something}"/>

</apex:selectList>

 

<apex:selectList value="{!Courseid}" size="1" id="Course"  >
                    <apex:selectOptions value="{!Courseval}"/>
                    <apex:actionSupport event="onchange" action="{!nothing}" status="status" reRender="btnsave,btncncel"/>
  </apex:selectList>

 

controller:

public string getstreamid()
    {
        return streams;
    }
    public void setstreamid(string s)
    {       
        this.streams=s;
    }
    public list<selectoption> getstreamval()
    {
        list<selectoption> values=new list<selectoption>();
       
        values.add(new selectoption('Import','Import'));
        values.add(new selectoption('Export','Export'));
        values.add(new selectoption('UnAcommpanied','UnAcommpanied'));
        values.add(new selectoption('Form X','Form X'));
       
        return values;
    }
    public string getcourseid()
    {
        return courses;
    }
    public void setcourseid(string s)
    {
        this.courses=s;
    }
    public void nothing()
    {
        crsechange='change';
    }
    public void something()
    {
        crsechange=' ';
    }
    public list<selectoption> getcourseval()
    {
        List<SelectOption> values = new List<SelectOption>();       
        if(streams==' ')
        {
       
        }
        if(streams=='IMPORT')
        {
            values.add(new selectoption('B E HOME','B E HOME')); 
            values.add(new selectoption('WAREHOUSE BE','WAREHOUSE BE'));
            values.add(new selectoption('EX BOND','EX BOND'));
            values.add(new selectoption('100%E.O.U','100%E.O.U'));
            values.add(new selectoption('SEZ','SEZ'));
            values.add(new selectoption('OTHERS','OTHERS'));
        }
      
        if(streams=='EXPORT')
        {
            values.add(new selectoption('FREE SB','FREE SB')); 
            values.add(new selectoption('DUTY SB','DUTY SB'));
            values.add(new selectoption('DBK SB','DBK SB'));
            values.add(new selectoption('100%E.O.U','100%E.O.U'));
            values.add(new selectoption('SEZ','SEZ'));
            values.add(new selectoption('OTHERS','OTHERS'));
        }
        if(streams=='UnAcommpanied')
        {
            values.add(new selectoption('TR','TR')); 
            values.add(new selectoption('NON TR','NON TR'));
            values.add(new selectoption('NON TR','NON TR'));
        }
        if(streams=='FORM X')
        {
            values.add(new selectoption('CARNET','CARNET'));
            values.add(new selectoption('OTHERS','OTHERS'));
        }
        return values;
    }

 

Is there any another way to do save the dependent picklist values or else any corrections in this code.here i am overriding the standard save controller.if it is possible in some other way give me some example code.plz tell me

 

Thanks in advance,

Manu