I need to display record data in a separate section based on changing a values in picklist.Trying to call a method in apex using actionsupport but it failed to call method. here is my code. VF Page:

<apex:form >
    <apex:pageBlock >
        <apex:pageBlockSection >

            <apex:selectList id="sList" value="{!selectedSite}" multiselect="false" size="1"> 
                <!---<apex:selectOption itemvalue="None" itemLabel="--None--"/>-->

                <apex:selectOptions id="domainnames" value="{!SiteDetails}">                        
                <apex:actionSupport id="callController" event="onchange" reRender="DisplaySiteDetails" action="{!showRelatedData}">
                        <apex:param name="passval" value="" assignTo="{!selectedValue}"/>




           <apex:outputPanel id="DisplaySiteDetails">


public List<string> selectedSite{get;set;}
public string selectedValue{get;set;}
public List<selectOption> getSiteDetails()
    List<selectOption> multiSites = new List<selectOption>();

    for(SP001_MyDev__CB_Settings__c siteName:siteList)
        string domain = siteName.Name;
        multiSites.add(new SelectOption(domain,domain));
    return multiSites;
public PageReference showRelatedData()
    string passedParam = Apexpages.currentPage().getParameters().get('passval');
    system.debug('selected value:'+passedParam);
    system.debug('selected value:'+selectedValue);
    return null;

here this showRelatedData() method is not getting called.

  • is this your complete vf page code? I don't see you are calling your controller in your vf page. – Himanshu Dec 16 '18 at 14:22
  • calling controller in apex:page..this is only half of the code..but now the method is getting called..the mistake was i have defined List<string> selectedSite,it should be only string type.but how would I pass my selected value to the method.using param I am not getting any valu. – sivanee Dec 16 '18 at 14:45

There's no need to pass a parameter here. Just read the value directly from selectedSite. The reason you typically use an apex:param is when you need to pass in additional data, such as if you have a list of records and you want to pass in the value of the record to be affected:

<apex:repeat value="{!contacts}" item="contactRecord">
      <apex:selectList value="{!contactRecord.Title}">
        <apex:selectOptions value="{!titles}" />
        <apex:actionSupport event="change" action="{!saveTitle}" reRender="form">
          <apex:param name="changedId" value="{!contactRecord.Id}" assignTo="{!updatedRecordId}" />

There's rarely any use for an apex:param outside of the iterator use-case for actionSupport, since the values are already updated as part of the postback.

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.