Actionsupport in visualforce in salesforce

actionsupport in visualforce

actionSupport component adds AJAX support to other components in visualforce. It allows components to be refreshed asynchronously by calling the controller’s method when any event occurs (like click on button). It allows us to do partial page refresh asynchronously without refreshing  full page.

In the example below, initially count value is set to 0. But when we will click on ‘Click here to increment! ‘, then controller action method will be called and count will be incremented. Also outputText component will be rendered without refreshing complete page.

Similarly when we will click on ‘Click here to decrement!’, then controller action method will be called and count will be decremented. Also outputText component will be rendered without refreshing complete page.

apex:actionSupport has following attributes in our example:

  • action: action attribute specifies the controllers action method that will be invoked when event occurs.
  • event: It is DOM event that generates AJAX request
  • reRender: It is comma separated id’s of components that needs to be partially refreshed. In our example, we have given its value as ‘out’. So component with ‘out’ id will be refreshed without refreshing complete page.

Click for Demo

Visuaforce Code:

<apex:page controller="actionSupportController">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection >
                <apex:outputpanel id="panel1">
                    <apex:outputText value="Click here to increment!"/>
                    <apex:actionSupport event="onclick" action="{!incrementCounter}" rerender="out"/>

                <apex:outputpanel id="panel2">
                    <apex:outputText value="Click here to decrement!"/>
                    <apex:actionSupport event="onclick" action="{!decrementCounter}" rerender="out"/>

                <apex:outputText value="{!count}" id="out" label="Count Is:"/>


Apex Code:

public class actionSupportController {
    Integer count = 0;

    public PageReference incrementCounter() {
            return null;

    public PageReference decrementCounter() {
            return null;

    public Integer getCount() {
        return count;

Permanent link to this article:


    • Raghu on November 18, 2020 at 12:27 pm
    • Reply

    Very Clear Thanks

    • neha on October 29, 2021 at 7:25 pm
    • Reply


    Not getting the selected picklist from popup to controller during the Save operation. By system admin sometime value is populating some times does not work.

    I have checked the debug log but on save method i am not receiving the value.

    (276603249)|USER_DEBUG|[249]|DEBUG|set values 06:34:44.0 (277193017)|VF_PAGE_MESSAGE|Please choose the other value or selected value is blank

    The vf code where i am facing the issue:

    <!– –>


    Apex controller: i am using the wrapper class

    public PageReference Save(){
    // collectedStr = selectedStr;
    system.debug(‘set values of tempStr ‘+selectedStr); // Not getting the value
    opp.Assumed_Carrier_Branch__c = collectedStr;
    update opp;
    PageReference pg = new PageReference( ‘/’ + OppId );
    return pg;
    //to get the picklist i have used this method

    for (Id s1 : statusFieldCategory.keySet())
    system.debug(‘S1 value’+ s1);
    List strlist= new List();
    strPASplit = statusFieldCategory.get(s1).split(‘;’);
    for(String s: strPASplit){
    system.debug(‘string value’+s);

    SelectOption op = new SelectOption(s,s);

    system.debug(‘inside the forloop strlist’+strlist);

    // put picklist values into an tag for VF display
    if(primaryIDs != null && (!primaryIDs.contains(s1)))
    system.debug(‘primaryId’ +primaryIDs);
    system.debug(‘catergorylist’ +categoryList);
    strlist.add(new SelectOption(”,’–None–‘));
    countOption = count;
    strPASplit = new List();
    system.debug(‘count option’+countOption);
    return categoryList;


Leave a Reply

Your email address will not be published.