Friday, September 5, 2014

What is action support salesforce?

What is action support salesforce?

Action support component adds AJAX support to another component, this allows the component to call a controller method when a particular event occurs(for example onlcik, onblur etc). It also allows to rerender,rendere page sections as desired.

In the following example a controller method is called when you click within a textbox using actionsuppot component.

Controller :

Public with sharing class DemoController {
Public String outValueSecond{get;set;}
Public String outvalue{get;set;}
Public boolean flag{get;set;}
  Public DemoController(){
     outvalue = 'Before Value';
     outValueSecond = 'before value set in constructor';
  Public void DemoMethod(){
   outValueSecond = 'After value set in controller method. This method is called using action support added to inputtext compoennt';

Visualforce Page: 

<apex:page controller="DemoController">
   <apex:form >
       <apex:pageBlock >
             Click Inside this block <apex:inputtext >
            <apex:actionSupport event="onclick" action="{!DemoMethod}" rerender="pgblck"/>
       <apex:pageblock id="pgblck">
             <apex:outputText value="{!outValueSecond }"/>

In this example initially the lower pageblock has a value that is set in constructor, but when the mouse is clicked in the text box the controller method is called which changes the value of the variable that is displayed in the lower pageblock. The controller is called by using action support for the inputtext. The action support also rerenders the lower page block which refreshes the lower block and hence shows the new value set in controller method.


Rstrainings said...

thank you for nice information,
Salesforce online training in USA
Salesforce online training in india

Post a Comment

| ,