+ Start a Discussion
PRIYAPRIYAPRIYAPRIYA 

action attribute in <apex:page>

Hi,

 

Please let me know in which scenarios, the action attribute in <apex:page> is used? Kindly give an example program for the same.

 

Thanks.

PremanathPremanath

Hi priya

  

   If we want to call action method from vf page to class on Pageload, we write action method in apex:page.

   

   For example your writing code for Addition program.

   When we click on Button Add  action fucntion will call. Like this

  <apex:commandbutton value="ADD" action="{!Add}"/>

 

 In above example your calling the action function on Button click.

 

 But if we want to call action function on page load ,Based on our requirement we use the action attribute in <apex:page>

 

 

Regards

Prem

 

bob_buzzardbob_buzzard

This allows you to take action prior to the page rendering.  The main use I've found is deciding whether the user should stay on this page or be directed elsewhere.  For example, if a visualforce page overrides a record view for everyone apart from the system administrator, the profile of the user can be checked via merge syntax on the page or via an action method, and if the user is a sysadmin they can be sent elsewhere.  All of this happens before any part of the page is displayed.