LaceySnr.com - Salesforce Development Posts by Matt Lacey

Head Banger

Posted: 2010-07-27

Last night I spent around half an hour trying to work out why my constructor wasn't running in a Visualforce controller class. The code was your regular stuff, looking like this:

public with sharing class MyController
{
    public    boolean mp_bMemberVar {get; set;}

    public void MyController()
    {
        // stuff
    }

    public void Init()
    {
        // etc..
    }
}

Can you spot the problem? Somehow in my haste I'd included the void keyword in there... so my constructor wasn't a constructor at all and as such, not being called when I expected it to. A warning on save would have been nice!