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
Ashritha ReddyAshritha Reddy 

Action support issue?

action support means a component that adds an ajax support to another component,allowing the component  to be refreshed asynchronously by the server when a particular even occurs

now my doubt is how the event can establish the relation between components to the server..can any one give me the examples please?
nagendra 6989nagendra 6989
Hi Ashritha Reddy,

As i understand that you want to know how the relation gets established between a component and server when action support is used ......

Action Support : 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.

Example : 

VisualForce Page :

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

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

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

            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Controller Page  : 

public class actionSupportController {
    Integer count = 0;

    public PageReference incrementCounter() {
            count++;
            return null;
    }

    public PageReference decrementCounter() {
            count--;
            return null;
    }

    public Integer getCount() {
        return count;
    }
}

Screenshot for action support

You can also check the below links for more exapmles................

1)http://sfdcsrini.blogspot.com/2014/08/simple-ajax-example-using-visualforce.html

2)http://sfdcsrini.blogspot.com/2014/09/what-is-action-support-salesforce.html

Please let me know if it helps you...............

Thanks & Regards 
Nagendra.P
9848950830