0

What it means - private final Account account. Please expalin this line by line

public class MyController {

    private final Account account;

    public MyController() {
        account = [SELECT Id, Name, Site FROM Account 
                   WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
    }

    public Account getAccount() {
        return account;
    }

    public PageReference save() {
        update account;
        return null;
    }
}
1
  • 2
    I suggest you do some Googling to learn more yourself. This site is focussed on specific questions and answers not on broad explanations.
    – Keith C
    Commented May 4, 2016 at 19:19

1 Answer 1

1

Well, it's the most basic example of a Custom Controller.

As the Account is private you have to the declare the getAccount() method to access it from the VisualForce page.

The constructor get the id of the current Account, as I suppose that the controller is an extension for the standardControllerAccount.

The save() method allows the VF page to bind a button to this method in order to save the changes the user has done in what I suppose is a form in the VF.

That's all. But I think you should take some trailhead or something like that.

Not the answer you're looking for? Browse other questions tagged .