# Actionsupport is not calling method in apex controller

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:actionRegion>

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

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

</apex:selectList>

</apex:actionRegion>

</apex:pageBlockSection>

</apex:pageBlock>
<apex:outputPanel id="DisplaySiteDetails">
<apex:outputText>Hello</apex:outputText>
</apex:outputPanel>
</apex:form>


Controller:

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;
system.debug('DomainName:'+domain);
system.debug('SiteName:'+multiSites);
}
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">
<tr>
<td>{!contactRecord.Name}</td>
<td>
<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}" />
</apex:actionSupport>
</apex:selectList>
</td>
</tr>
</apex:repeat>


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.