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
SakthidasanSakthidasan 

Action support in visual force page

why we need to use action support  in visualforce page in real time? what is the need of using action support? 
Best Answer chosen by Sakthidasan
Mahesh DMahesh D
Hi Sakthi,

apex:actionSupport
A component that adds AJAX support to another component, allowing the component to be refreshed asynchronously by the server when a particular event occurs, such as a button click or mouseover.

Simple example is here:
<!--  Page: -->
<apex:page controller="exampleCon">
    <apex:form>
        <apex:outputpanel id="counter">
            <apex:outputText value="Click Me!: {!count}"/>
            <apex:actionSupport event="onclick" 
                                action="{!incrementCounter}" 
                                rerender="counter" status="counterStatus"/>
        </apex:outputpanel>
        <apex:actionStatus id="counterStatus" 
                           startText=" (incrementing...)" 
                           stopText=" (done)"/>
    </apex:form>
</apex:page>	

/***  Controller: ***/
public class exampleCon {
    Integer count = 0;
                        
    public PageReference incrementCounter() {
            count++;
            return null;
    }
                    
    public Integer getCount() {
        return count;
    }
}
Scenario 1:

Here whenever you click on the Text "Click Me" it will increment the counter. Here the whole page is not submitting, its refreshing (rerendering) part of the page. (Above example)

Scenario 2:

If you want to add rows dynamically then we will use actionSupport to implement.

Scenario 3:

On the VF page, once the User provides the billing address and a checkbox to copy the shipping address then using the action support we can achieve it.


Also look into the below links for more information

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_actionSupport.htm

http://sfdcsrini.blogspot.com/2015/02/how-to-use-apexactionsupport-tag-in.html

http://www.sfdcpoint.com/salesforce/actionsupport-visualforce-salesforce/

http://salesforceprasad.blogspot.com/2014/11/visualforce-actionsupport-examples.html

http://www.cloudforce4u.com/2013/07/action-support-salesforce.html

http://salesforce.stackexchange.com/questions/60609/how-to-use-actionsupport-actionregion-actionfunction-all-together


Please do let me know if it helps you.

Regards,
Mahesh

All Answers

Praveen KHariPraveen KHari
ActionSupport : A component that adds AJAX support to another component, allowing the component to be refreshed asynchronously by theserver when a particular event occurs, such as a button click or mouseover.
 
Used when we want to perform an action on a perticular eventof any control like onchange of any text box or picklist

 
Mahesh DMahesh D
Hi Sakthi,

apex:actionSupport
A component that adds AJAX support to another component, allowing the component to be refreshed asynchronously by the server when a particular event occurs, such as a button click or mouseover.

Simple example is here:
<!--  Page: -->
<apex:page controller="exampleCon">
    <apex:form>
        <apex:outputpanel id="counter">
            <apex:outputText value="Click Me!: {!count}"/>
            <apex:actionSupport event="onclick" 
                                action="{!incrementCounter}" 
                                rerender="counter" status="counterStatus"/>
        </apex:outputpanel>
        <apex:actionStatus id="counterStatus" 
                           startText=" (incrementing...)" 
                           stopText=" (done)"/>
    </apex:form>
</apex:page>	

/***  Controller: ***/
public class exampleCon {
    Integer count = 0;
                        
    public PageReference incrementCounter() {
            count++;
            return null;
    }
                    
    public Integer getCount() {
        return count;
    }
}
Scenario 1:

Here whenever you click on the Text "Click Me" it will increment the counter. Here the whole page is not submitting, its refreshing (rerendering) part of the page. (Above example)

Scenario 2:

If you want to add rows dynamically then we will use actionSupport to implement.

Scenario 3:

On the VF page, once the User provides the billing address and a checkbox to copy the shipping address then using the action support we can achieve it.


Also look into the below links for more information

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_actionSupport.htm

http://sfdcsrini.blogspot.com/2015/02/how-to-use-apexactionsupport-tag-in.html

http://www.sfdcpoint.com/salesforce/actionsupport-visualforce-salesforce/

http://salesforceprasad.blogspot.com/2014/11/visualforce-actionsupport-examples.html

http://www.cloudforce4u.com/2013/07/action-support-salesforce.html

http://salesforce.stackexchange.com/questions/60609/how-to-use-actionsupport-actionregion-actionfunction-all-together


Please do let me know if it helps you.

Regards,
Mahesh
This was selected as the best answer