Activity Forums Salesforce® Discussions What is the Action attribute of apex:page for initialization in Salesforce?

  • Manpreet

    April 26, 2018 at 4:28 pm

    Hi saurabh,

    The reason that we don't suggest doing initialization there is because we don't promise that your controller methods will fire in any particular order, other than that your constructor will be called first.If you want to do initialization you should do it in the constructor of your controller, since that will happen when the instance of the class is created. The action attribute is really only useful for redirecting, specifically conditional redirecting.


  • Aman

    April 26, 2018 at 7:50 pm

    Hi Saurabh,

    The action method invoked when this page is requested by the server. Use expression language to reference an action method. For example, action="{!doAction}" references the doAction() method in the controller.If an action isn’t specified, the page loads as usual. If the action method returns null, the page simply refreshes.

    This method is called before the page is rendered, and allows you to optionally redirect the user to another page.

    Important: This action should not be used for initialization or DML.


  • Sales

    February 28, 2019 at 9:51 am

    Hi All,

    Found new content, it might worth your read


Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos