There are following action components in VF page:
- apex:actionSupport
- apex:actionStatus
- apex:actionRegion
- apex:actionPoller
- apex:actionFunction
apex:actionSupport:
- As name itself suggested, actionSupport provide the support to action of the other component.
- Provides support for invoking controller action methods from other Visualforce components.
<apex:page
>
<apex:form>
<apex:pageBlock>
<apex:sectionHeader
title="Rerender Example"/>
<apex:commandButton value="Click
here!">
<apex:actionSupport
event="onmouseover" rerender="time" status="refreshstatus"/>
</apex:commandButton>
<apex:actionStatus
id="refreshstatus" startstyle="color:green;" startText="Refreshing...."></apex:actionStatus>
<apex:outputpanel
id="time">
<apex:outputtext
value="{!NOW()}"/>
</apex:outputpanel>
</apex:pageBlock>
</apex:form>
</apex:page>
Explanation
<apex:actionSupport event="onmouseover"
rerender="time" status="refreshstatus"/>
The event attribute determines which action
should refresh the page, we have a onmouseover. That's why when you move the
mouse over the command button, the time gets refreshed..
The rerender attribute determines the
portion of the page to be refreshed. We have "time" which is the ID
of the portion to be refreshed....
The actionstatus attribute determines the
status message to be displayed when the refresh takes place. We have
"refreshstatus" which is the ID of the associated
"actionstatus" tag.
apex:actionStatus
- Displays the status of an AJAX update request.
- An AJAX request can either be in progress or complete.
- When some operation is happening in the back ground then it will show processing message to the user so that she/he can wait.
- Refer the above example
apex:actionRegion
- actionRegion provides an area of a Visualforce page that decides and separates which components should be processed by the force.com server when an AJAX request is generated.
- Only the components which are inside actionregion component are processed by server, so it increases visualforce page performance.
- Refer http://www.sfdcpoint.com/salesforce/actionregion-visualforce-salesforce/ blog for the more details
apex:actionPoller
- A timer that sends an AJAX update request to the server according to a time interval that you specify
<apex:page controller="exampleCon">
<apex:form>
<apex:outputText value="Watch
this counter: {!count}" id="counter"/>
<apex:actionPoller
action="{!incrementCounter}" rerender="counter"
interval="15"/>
</apex:form>
</apex:page>
Apex
Code:
public
class exampleCon {
Integer count = 0;
public PageReference incrementCounter() {
count++;
return null;
}
public Integer getCount() {
return count;
}
}
- Used to call the action method of the controller from the JavaScript
- An <apex:actionFunction> component must be a child of an <apex:form> component.
Note:
Rerender
is used when you want to refresh only a portion of your visualforce page when
the user does some action... This would actually improve the user interface and
reduce processing time
No comments:
Post a Comment