Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I am attempting to convert my page to work from List View button into Detail Page button.

When I attempt to remove the recordsetvar, I get the mentioned error.

Unknown constructor 'AddBasketGasQuoteFromMonitor.AddBasketGasQuoteFromMonitor(ApexPages.StandardSetController controller)

Below are pieces of code:

VF

<apex:page standardController="Line_del__c" recordSetVar="recrec" extensions="AddBasketGasQuoteFromMonitor">

Apex

  public with sharing class AddBasketGasQuoteFromMonitor{
    Public List<WrapperClassEx> WrapperList{get;set;}
    public AddBasketGasQuoteFromMonitor(ApexPages.StandardSetController controller) {
      mycon = controller;
      Selectedmeters = mycon.getSelected();
    }
    public List<sobject> Selectedmeters {get; set;} 
    ApexPages.StandardSetController mycon; 
   Public List<WrapperClassEx> getwrapperObj(){
      List<electricity_meter__c> MeterList = [Select id,name,AQ__c,meter_details__c from electricity_meter__c where Linked_Monitor_Line__c in: SelectedMeters]; 

The last line is where I need to use my ID (should be Linked_Monitor_Line__c=SelectedMeters). I know I can get the Id by doing something like: Id recordId = standardController.getId(); but I realize in this case it's different?

share|improve this question
    
Please be more specific - I currently can't understand what you want to achieve. Could you provide us with more data or edit your question? –  Artur Kępczyński Feb 21 at 15:33
add comment

2 Answers 2

up vote 4 down vote accepted

According to Building a Controller Extension I think you should have a constructor with ApexPages.StandardController as a parameter:

public with sharing class AddBasketGasQuoteFromMonitor{
    Public List<WrapperClassEx> WrapperList{get;set;}
    public AddBasketGasQuoteFromMonitor(ApexPages.StandardController controller) {
      // this is new constructor which should fix your problem
    }
    public AddBasketGasQuoteFromMonitor(ApexPages.StandardSetController controller) {
      mycon = controller;
      Selectedmeters = mycon.getSelected();
    }
    public List<sobject> Selectedmeters {get; set;} 
    ApexPages.StandardSetController mycon; 
   Public List<WrapperClassEx> getwrapperObj(){
      List<electricity_meter__c> MeterList = [Select id,name,AQ__c,meter_details__c from electricity_meter__c where Linked_Monitor_Line__c in: SelectedMeters];
share|improve this answer
    
Thank you so much, this solved my problem completely! Can you just explain what I have done here? –  dzh Feb 21 at 16:22
    
I think you can still use your controller for set of data. But sfdc insist on constructor with standard controller. –  Chiz Feb 21 at 16:38
add comment

If you are not using recordSetVar then your Controller Extension constructor needs to take an ApexPages.StandardController argument rather than a ApexPages.StandardSetController argument.

See the documentation here for more information.

A controller extension is any Apex class containing a constructor that takes a single argument of type ApexPages.StandardController or CustomControllerName, where CustomControllerName is the name of a custom controller you want to extend.

You can then get the current record using the StandardController.getRecord() method which is documented here.

getRecord()
Returns the record that is currently in context, based on the value of the id query string parameter in the Visualforce page URL.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.