Action
Function Actin Support Action Region Action Poller
========================================================================
Action
Function: –
========================
Action
Function is used in the Visualforce page to call the Service Side method using
JavaScript and
does
not add the Ajax Request before calling the Controller method.
<apex:actionFunction name=”myactionfun”
action=”{!actionFunctionTest}” reRender=”pgBlock, pbSection” />
Let
us talk about above example. In any Javascript Method where the name of
ActionFunction
(
In our example myactionfun() ) will be invoked, it will call the controller
method name
actionFunctionTest.
Example myactionfun();
Action
Support: –
=======================
As
the name indicates action support is used to provide the support to the input
field where
we
can not get event either manually or external event. It adds the AJAX request
to VF page and
then
Calls the Controller method. For
For
example, if we want to call any server side method when input changes then we
will go for
action
support because we can not get any event for this.
<apex:inputText value=”{!dummyString}” >
<apex:actionSupport event=”onchange”
action=”{!actionSupportTest}” reRender=”pgBlock, pbSection” />
</apex:inputText>
Action
Poller: –
=======================
A
timer that sends an AJAX request to the server according to a time interval
that you specify. Each
request
can result in a full or partial page update.
apex:actionPoller action=”{!incrementCounter}”
reRender=”counter” interval=”15″ enabled = “true” />
Enabled
attribute is used to make poller as active or inactive by default value is
true.
If
we provide false then poller will be inactivate.
========================================================================
VisualForce
Page:::------------
<apex:page
controller="ActionFuctionSupportDemoController">
<apex:slds />
<apex:form >
<script>
function javaScriptMethod(){
alert('Calling Action Function');
myactionfun();
}
</script>
<apex:actionFunction
name="myactionfun"
action="{!actionFunctionTest}" reRender="pgBlock,
pbSection" />
<apex:pageBlock title="Test
Action Support/Function Test">
<apex:pageblockSection >
<apex:inputText
value="{!dummyString}" >
<apex:actionSupport
event="onchange" action="{!actionSupportTest}"
reRender="pgBlock, pbSection" />
</apex:inputText>
<apex:inputcheckbox
onclick="javaScriptMethod();" />
</apex:pageblockSection>
</apex:pageBlock>
<apex:pageblock title="Output of
Action Funtion/Support" id="pgBlock">
<apex:pageblockSection
id="pbSection" >
{!actionFunTest}
</apex:pageblockSection>
</apex:pageblock>
<apex:pageBlock title="Action
Poller Block ">
<apex:pageBlockSection >
<apex:outputText
value="Watch this counter: {!count}" id="counter"/>
<apex:actionPoller
action="{!incrementCounter}" reRender="counter"
interval="10"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
----------------------------------------------------------------------------------------------------
Apex Class :---
public
class ActionFuctionSupportDemoController{
public static String actionFunTest { get;
set; }
public static String dummyString { get;
set; }
Integer count = 0;
public void actionFunctionTest(){
actionFunTest = 'Value from Action
Function';
}
public void actionSupportTest(){
System.debug('#### Action Support
Called');
actionFunTest = 'Value from Action
Support '+dummyString;
}
public PageReference incrementCounter() {
count++;
return null;
}
public Integer getCount() {
return count;
}
}
----------------------------------------------------------------------------------------------------
No comments:
Post a Comment