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
MelliottMelliott 

Mutli - Select Picklist values not rerendering page

I have a multi select picklist that rerenders sections of a page.  It currently only works if one value is selected.  How do I get it to work if two values are selected. 

 

Here is a section of the page.

 

 

  <apex:pageBlockSection title="ED Experience" id="ED" columns="1"
                                                 rendered="{!isFT}" >
                                                 
            <apex:OutputText style="font-size: larger; font-weight: bold;" value="Please provide a brief summary of your Emergency Department experience."/>                                                      
                <apex:inputField value="{!application.ED_Experience__c}"/>
                </apex:pageBlocksection>     
            <apex:pageBlockSection title="Emergency Department Physician's Certification of Competency" id="CTED" columns="1"
                                                 rendered="{!isFT}">

 

 

Here is the pertinent pieces of the controller

 

 

 private Set<String> EDtypes = new Set<String> {'ED Full Time', 'ED Part Time'};
    private Set<String> Midtypes = new Set<String> {'Fast Track Full Time','Fast Track Part Time','Clinic Part Time','Clinic Full Time'};
    private Set<String> EDMidtypes = new Set<String> {'ED Full Time', 'ED Part Time','Fast Track Full Time','Fast Track Part Time','Clinic Part Time','Clinic Full Time'};
    private Set<String> Hosptypes = new Set<String> {'Hospitalist Full Time','Hospitalist Part Time'};


  public Boolean getIsFT () {
       return EDtypes.contains(application.Practice_Preference__c);
   }
   
      public Boolean getIsFTMID () {
       return EDMidtypes.contains(application.Practice_Preference__c);
    }
    
    public Boolean getIsMid() {
        return Midtypes.contains(application.Practice_Preference__c);
    }
    

 

I tried changing IsFT to IsFTMid in the VF page but it does not render when both ED Full time and Clinic Full Time (for example) are selected.  Any  help is greatly appreciated.

 

bob_buzzardbob_buzzard

Can you show us the code that controls the re-rendering?  Presumably there is a command button or similar?

bob_buzzardbob_buzzard

Looking in more detail, the rerendering probably isn't important.

 

When you choose multiple items from a multi-select picklist, they are stored in the field as a semi-colon separated string, so when you examine your sets to see if they contain the value, they wont'!

 

You'll need to iterate the field contents and compare each element.

 

Something like:

 

 

public Boolean getIsFT () {
       String[] prefs=application.Practice_Preference__c.split(';');
       Boolean result=false;
       for (String pref : prefs)
       {
          if (EDtypes.contains(pref))
          {
             result=true;
          }
       }

       return result;
 
   }