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
Jina ChetiaJina Chetia 

Refresh for Dependent Picklist does happen more than once whenever any value is changed

Hi,

I have two picklist REGION and TERRITORY and the TERRITORY picklist values are dependent on REGION. I have used the following link to make my depending picklist http://wiki.apexdevnet.com/index.php/Extended_Functionality_of_Visualforce_-_Part_2 but the refresh happens only once. The second time I change my REGION value the TERRITORY does not get refreshed.

Here is  the piece of code
Code:
    <apex:pageBlock title="Section 2" rendered="{!showSecondSection}">
                        <p>To what geography does this rate apply— </p>
                        Region: <span style="padding:10px;"/>
                           <apex:actionFunction action="{!refreshPage}" name="refreshPage"/>
                         <apex:selectList value="{!contractTerms.REGION__c}" id="region" size="1">
                              <apex:selectOptions value="{!regionList}"/>
                              <apex:actionSupport event="onchange" rerender="territory"/>
                           
                         </apex:selectList>
                        
                        <p> Territory: <span style="padding:10px;"/>
                         <apex:selectList value="{!contractTerms.TERRITORY__c}" multiselect="true" id="territory" disabled="{!ISNULL(contractTerms.REGION__c)}">
                            <apex:selectOptions value="{!territories}"/>
                        </apex:selectList><p/>
                       <!-- <apex:inputField id="territory" value="{!contractTerms.TERRITORY__c}"/> --></p>
                        <p><span style="padding:10px;"/><apex:commandButton action="{!showSection3}" value="Continue" styleClass="btn"></apex:commandButton></p><br/>
                </apex:pageBlock>


Controller

 
    public List<SelectOption> getTerritories()
    {
        REGION__c region = null;
        List<REGION_TERRITORY__c> territoryList = new List<REGION_TERRITORY__c>();
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('','--None--'));
    
       if(contract_terms.REGION__c != null)
        {
           
            region = [select id, Name from REGION__c where Id =:contract_terms.REGION__c];
            territoryList = [select id, Name from REGION_TERRITORY__c where Region__c=:region.Id];
        }
          
        for(REGION_TERRITORY__c territory: territoryList )
        {
        
             options.add(new SelectOption(territory.Id,territory.Name));
        }
       
        return options ;
    
    }
    public List<SelectOption> getRegionList()
    {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('','--None--'));
        List<REGION__c> regionList = [select id, Name from REGION__c];
        
        for( REGION__c region:regionList)
        {
               options.add(new SelectOption(region.Id,region.Name));
       
        }
        return options;
    
    }
   


Can anyone please help me ?

Thanks
Jina
 

indicatorindicator

Jina,

I'm having the same thing happen to me (just started this morning).  Are you on the na2 server, and were the refreshes working previously?  I cannot make any changes to a page after the initial save.  I save the changes, but nothing happens.

jwetzlerjwetzler
Hi Jina.  One of my team members and I looked into this and we discovered there's a bug (not a new one, it has been around for some time) in the way multiselect components handle null values.  actionSupport is submitting your form via an ajax request, and it's causing your setter to be called on your territory selectList, which at the time does not have a value.  If you changed that to multiselect="false" I suspect it would work for you.

I have logged a bug for this and we will hopefully get it fixed very soon.  Sorry for any inconvenience.

Jill
Jina ChetiaJina Chetia
Thanks. Can you please let me know when this bug is fixed. Is there any alternative that I can try?

Jina
jwetzlerjwetzler
Aside from making the picklist single select I can't find a workaround.
mfoxmfox
This bug has been fixed and should go out in the next patch release.

Mark Fox
Jina ChetiaJina Chetia

I tested the code with the lastest release, the multi-selection works fine but there is still some issues with respect to mapping of the fields to any input field or simple String data type. I get a conversion error. I get this error where TERRITORY__c is a multiselet picklist field

Conversion Error setting value 'New Zealand Singapore' for '#{contractTerms.TERRITORY__c}'.

I also tried setting it to a String datatype, even then I got a conversion error
Conversion Error setting value 'New Zealand Singapore' for '#{territoryValue}'.
 
Do I have to make some other settings opr implement it in a different way to make it work. I had made no changes in the code sent earlier in the mail except for multiselect="true"
 
Thanks
Jina
mfoxmfox
I'll have a look at it and get back to you. The test case I was using involved an empty array causing the conversion error. This looks to be something different.