[SalesForce] Unknown constructor for visualforce controller

I'm trying to make my Visualforce controller work correctly. Bear with me that i'm also using a wrapper class in the controller, and it's my first time doing that an I've been getting lots of errors, both with the controller class and the page. What am I obviously overlooking in this first code draft?

What this class does is fetch data from an eternal webservice as XML, iterates over it, creates a new instance of my class for each and returns a list of them to the page. I waant to be able to use to iterate over the list and display on the page. Where i'm stuck at the moment is that whenever I try to save the current page code, it throws this error:

Unknown constructor 'WSC_GetSMSNotifications.WSC_GetSMSNotifications() 

First off, the page:

 <apex:page showHeader="false" sidebar="false" controller="WSC_GetSMSNotifications">
<apex:sectionHeader title="SMS List" subtitle="List" />
<apex:form>
Phonenumber:  <apex:inputText id="phone" label="Phone number"/>
Choose # of months: <apex:selectOptions value="{!months}"/>
<apex:commandButton id="theButton" value="Get List" onclick="{!getList}"/>
</apex:form>

<apex:pageBlock title="Notifications">
<tr>
    <th>Type</th>
    <th>Status</th>
    <th>Text</th>
    <th>Date</th>
</tr>
    <apex:repeat value="{!getlist}" var="noti" id="notify">
    <apex:column value="{!noti.status}"/>
    <apex:column value="{!noti.type}"/>
    <apex:column value="{!noti.text}"/>
    <apex:column value="{!noti.cDate}"/>
    </apex:repeat>
</apex:pageBlock>

The controller:

     public class WSC_GetSMSNotifications {


  //private final Contact con {get; private set;}

    public class Notifications{

        public String type {get;set;}
        public String status {get;set;}
        public String text {get;set;}
        public String cDate {get;set;}
  }



public WSC_GetSMSNotifications.Notifications() {}  


public List<Notifications> notifyList = new List<Notifications>();

public List<SelectOption> getMonths(){ 
List<SelectOption> months = new List<SelectOption>();
months.add(new SelectOption('1','1'));
months.add(new SelectOption('2','2'));  
months.add(new SelectOption('3','3'));
months.add(new SelectOption('4','4'));
months.add(new SelectOption('5','5'));
months.add(new SelectOption('6','6'));
  return months;
}


public WSC_GetSMSNotifications(ApexPages.StandardController standardController){}


public Notifications[] getlist(String mobileNumber, String dMonth) {

Notifications[] notList = new List<Notifications>();
/*  This is a generated apex class from a WSDL, hence the strange names and methods */
  NotificationServiceXmlnsExampleCom.NotificationPortEndpoint1 stub = new NotificationServiceXmlnsExampleCom.NotificationPortEndpoint1();
  NotificationService.SMS_element sms = new NotificationService.SMS_element();
  List<NotificationService.SMS_element> elemList = new List<NotificationService.SMS_element>();
  NotificationService.GetSMSByPhoneNumberInputT sInput = new NotificationService.GetSMSByPhoneNumberInputT();

  elemList = stub.GetSMSByPhoneNumber(mobileNumber,dMonth);
  system.debug('List is before insert '+notList);



 for(NotificationService.SMS_element e:elemList){

    Notifications noti = new Notifications();
    noti.type = e.Type_x;
    noti.status = e.Status;
    noti.text = e.Text;
    noti.cDate = e.CreationDate;
    notList.add(noti);
 }
  system.debug('List is now: '+notList);
  return notList;

    }
}

This controller should only work with custom data, and return custom data, so no actual Force.com objects are being used, that's why it's a controller and not a StandardController extension.

Best Answer

The zero-argument constructor is the "default constructor", but you only get it "for free" if you don't include any other constructors. Once you do, the zero-argument constructor has to be explicitly defined in order to work. Extensions use the one-argument Apexpages.StandardController controller constructor, or the Apexpages.StandardSetController controller constructor, but controller classes use the zero-argument constructor, since there is no StandardController to pass to the class.

At this point, you have three scenarios:

  1. You're using this class as an extension elsewhere, so you should add a zero-argument constructor so the class works in both places.

  2. You're not using this class as an extension elsewhere, and require no initialization, so you should remove this constructor and use the "default constructor".

  3. You're not using this class as an extension elsewhere, and require initialization, so you should provide a zero-argument constructor.