What is the use of ApexPages.StandardController? [closed]
What is the use of ApexPages.StandardController in the below? What is standard controller salsforce? Code
public class myControllerExtension { private final Account acct; public myControllerExtension(ApexPages.StandardController stdController) { this.acct = (Account)stdController.getRecord(); } public String getGreeting() { return 'Hello ' + acct.name + ' (' + acct.id + ')'; } }
Markup
{!greeting}
When this VisualForce page is loaded, two controllers are instantiated: the standardController for account, and your myControllerExtension. Your VisualForce page can call methos from either of those controllers: The standardController offers out-of-the-box operations like save (either create or update) or delete.
Your extension controller can offer custom operations to be performed on the record (in your case, getGreeting). In order to be able to use the standard operations in the 'standardController', when your extension controller is instantiated, it receives a reference to the standard controller (that's why you need a parameterised constructor). To clarify: the extension controller is not a child class; it's just another controller class that receives a reference to the standard controller Hope it helps!
Note: A StandardController salasforce object that is automatically provided for standard and all custom objects, bindable to a Visualforce page component with the “standardController” attribute. It provides a reference to a single/list of records to a set of common actions for data processing and default navigation.