1

I have built a custom controller and the constructor does not automatically invoked when the page is executed. What could be wrong in this? Am i missing something?

The System.debug('Inside Constructor...') never get executed.

public with sharing class MasterDataSyncController {
    public List<SFDCSAPDataDTO> lstSFDCSAP {get;set;}

    public void MasterDataSyncController() {
        System.debug('Inside Constructor...');
    }           

    public List<SFDCSAPDataDTO> getSFDCSAP() {
        Map<Id,Account> mpAccount = new Map<Id,Account> ([select Id, Name, Phone, Fax, 
                    BillingStreet, BillingCity, BillingState, BillingPostalCode, BillingCountry
                    from Account 
                    where (AccountNumber = null or AccountNumber <> '') and (Name <> null or Name <> '') order by Name]);
        System.debug('Account Map:'+mpAccount);

1 Answer 1

4

Constructors do not have a return value.

Remove void and it'll work, i.e.

public MasterDataSyncController() {
    System.debug('Inside Constructor...');
}  
2
  • Huh..Understood. That's a blatant mistake from my side. Thanks for pointing out.
    – Bforce
    Commented Jul 30, 2014 at 10:21
  • 1
    No worries bro - done it myself more than once. Commented Jul 30, 2014 at 10:22

You must log in to answer this question.

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