+ Start a Discussion
Prakhar GuptaPrakhar Gupta 

Action support Rerender not working

I have created a dependent pick list. I am populating the cities name based on the state but it is not working here is my code

<apex:pageBlock Title="New Case" mode="edit" id="Block">
        <apex:pageBlockSection title="Case Information" id="Block1" columns="2">

            <apex:pageblockSectionItem >
                <apex:outputLabel value="Status"/>
                <apex:outputText value="New"/>
            </apex:pageblockSectionItem>
            
            <apex:pageblockSectionItem >
                <apex:outputLabel value="Priority"/>
                <apex:selectList size="1" value="{!priority}">
                    <apex:selectOptions value="{!priorities}"/>
                </apex:selectList>
            </apex:pageblockSectionItem>
            <apex:pageblockSectionItem >
                <apex:outputLabel value="State"/>
                <apex:selectList size="1" value="{!state1}">
                    <apex:selectOptions value="{!states1}"/>
                    <apex:actionSupport event="onchange" reRender="a"/>
                </apex:selectList>               
            </apex:pageblockSectionItem>
            <apex:outputPanel id="a">
            <apex:pageblockSectionItem >
                <apex:outputLabel value="City"/>
                <apex:selectList size="1" value="{!city1}" id="a1">
                    <apex:selectOptions value="{!cities1}"/>
                </apex:selectList>
            </apex:pageblockSectionItem>
                </apex:outputPanel>
            </apex:pageBlockSection>

Thanks in advance.!!!
Sagar PareekSagar Pareek
do rerendering a1 works?
BalajiRanganathanBalajiRanganathan
are you implemented custom logic to show the dependent picklist values or using standard dependent picklist field?
if standard then, you dont need to use apex:selectOptions if you are using standard picklist fields and standard dependent picklist fields
use <apex:inputField value="{!city1}"> etc.
<apex:pageblockSectionItem >
     <apex:outputLabel value="Priority"/>
      <apex:inputField  value="{!priority}"/>
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
    <apex:outputLabel value="State"/>
    <apex:inputField  value="{!state1}"/
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
    <apex:outputLabel value="City"/>
    <apex:inputField  value="{!citi1}"/
</apex:pageblockSectionItem>

 
Prakhar GuptaPrakhar Gupta
Hi Sagar,

No rerendering a1 aslo not working. Please suggest.
Thanks.
Prakhar GuptaPrakhar Gupta
Hi Balaji R,

I am using custom login that has been written in "cities1" method of controller.
Thanks.
RishavRishav
Hii prakhar,
            please put your controller class so that we can see what is your logic so if any error can find(Remove you sensitive data) and then post

   
Prakhar GuptaPrakhar Gupta
Hi Rishav,

here is the controller code

public class Sample {

public List<SelectOption> getStates1()
    {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('None','--- None ---'));       
        options.add(new SelectOption('TN','Tamil Nadu'));
        options.add(new SelectOption('KL','Kerala'));
        return options;
    }
   
    public List<SelectOption> getCities1()
    {
        List<SelectOption> options = new List<SelectOption>();
        if(state == 'TN')
        {      
            options.add(new SelectOption('CHE','Chennai'));
            options.add(new SelectOption('CBE','Coimbatore'));
        }
        else if(state == 'KL')
        {      
            options.add(new SelectOption('COA','Coachin'));
            options.add(new SelectOption('MVL','Mavelikara'));
        }
        else
        {
            options.add(new SelectOption('None','--- None ---'));
        }     
        return options;
    }

}
Sforce.NinjaSforce.Ninja
@Prakhar
I tried this code on my Visualforce and it is working fine. My suspect is something interfering with your onchange? Is there any other javascript on the page. Check your javascript console for any errors. Or use the code below and start writing remaining code piece by piece.
<apex:page controller="Sample">
<apex:form >
<apex:pageBlock Title="New Case" mode="edit" id="Block">
        <apex:pageBlockSection title="Case Information" id="Block1" columns="2">

            <apex:pageblockSectionItem >
                <apex:outputLabel value="Status"/>
                <apex:outputText value="New"/>
            </apex:pageblockSectionItem>
            <apex:pageblockSectionItem >
                <apex:outputLabel value="State"/>
                <apex:selectList size="1" value="{!state}">
                    <apex:selectOptions value="{!states}"/>
                    <apex:actionSupport event="onchange" reRender="a"/>
                </apex:selectList>               
            </apex:pageblockSectionItem>
            <apex:outputPanel id="a">
            <apex:pageblockSectionItem >
                <apex:outputLabel value="City"/>
                <apex:selectList size="1" value="{!city}" id="a1">
                    <apex:selectOptions value="{!cities}"/>
                </apex:selectList>
            </apex:pageblockSectionItem>
                </apex:outputPanel>
            </apex:pageBlockSection>
           </apex:pageblock>
           </apex:form>
</apex:page>
 
public class Sample {
public string state{get;set;}
public string city{get;set;}
public List<SelectOption> getStates()
    {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('None','--- None ---'));       
        options.add(new SelectOption('TN','Tamil Nadu'));
        options.add(new SelectOption('KL','Kerala'));
        return options;
    }
   
    public List<SelectOption> getCities()
    {
        List<SelectOption> options = new List<SelectOption>();
        if(state == 'TN')
        {      
            options.add(new SelectOption('CHE','Chennai'));
            options.add(new SelectOption('CBE','Coimbatore'));
        }
        else if(state == 'KL')
        {      
            options.add(new SelectOption('COA','Coachin'));
            options.add(new SelectOption('MVL','Mavelikara'));
        }
        else
        {
            options.add(new SelectOption('None','--- None ---'));
        }     
        return options;
    }

}