+ Start a Discussion
Geoff SpozettaGeoff Spozetta 

Method does not exist or incorrect signature with controller creation

Hi All,

I'm currently following through a tutorial on how to display some records; I've gotten to a point where I've written the following Controller however I'm running into the following error:

Error: Compile Error: Method does not exist or incorrect signature: Database.getQueryLocater(List<innovation_orders__c>) at line 7 column 61. Full code code is below but the offending line is:
 
orderdets = new ApexPages.StandardSetController(Database.getQueryLocater(

My Code:
public class InnovationOrderingController {
//ApexPages.StandardSetController must be instantiated
//For standard list controllers
    public ApexPages.StandardSetController orderdets {
        get{
        if(orderdets == null) {
            orderdets = new ApexPages.StandardSetController(Database.getQueryLocater(
            [SELECT 
            Additional_Comments__c,
            Construction_Type__c,
            Contract_Signed_Date__c,
            CSA_ID__c,
            customer_site_id__c,
            Location_ID__c,
            Order_Completion_Date__c,
            Order_Status__c,
            Order_Type__c,
            Product_Instance_Number__c,
            Requested_Speed__c,
            Requested_Start_Date__c,
            Service_Status__c,
            site_name__c
            FROM innovation_orders__c]));
    }
    return orderdets;
    }
    set;
    }
//Initalize orderdets and return a list of records
    public List<innovation_orders__c> getOrderDets() {
        return (List<innovation_orders__c>) orderdets.getRecords();
    }
}


For reference, the sample code I'm trying to edit for my own purposes is:
public class opportunityList2Con {
    // ApexPages.StandardSetController must be instantiated
    // for standard list controllers
    public ApexPages.StandardSetController setCon {
        get {
            if(setCon == null) {
                setCon = new ApexPages.StandardSetController(Database.getQueryLocator(
                    [SELECT Name, CloseDate FROM Opportunity]));
            }
            return setCon;
        }
        set;
    }

    // Initialize setCon and return a list of records
    public List<Opportunity> getOpportunities() {
        return (List<Opportunity>) setCon.getRecords();
    }
}


Best Answer chosen by Geoff Spozetta
Richard TuttleRichard Tuttle
Oh hah, this one should have slapped me in the face.  The method name is getQueryLocator (note the o instead of an e).  That should solve your problem.

--Richard

All Answers

ProlayProlay
I tried the Custom List Controller for Contact and Position objects repectively. But getting the same error as you specified.
 
public class ContactTestController {
	
    public ApexPages.StandardSetController Concon {
        get{
        if(Concon == null) {
            Concon = new ApexPages.StandardSetController(Database.getQueryLocater([SELECT id, name FROM contact]));
    }
    return Concon;
    }
    set;
    }

    public List<contact> getContacts() {
        return (List<contact>) Concon.getRecords();
    }
}
 
public class PositionTestController {
	
    public ApexPages.StandardSetController poscon {
        get{
        if(poscon == null) {
            poscon = new ApexPages.StandardSetController(Database.getQueryLocater([SELECT id, name FROM position__c]));
    }
    return poscon;
    }
    set;
    }

    public List<position__c> getPositions() {
        return (List<position__c>) poscon.getRecords();
    }
}

Interestingly, this is working for the sample example on Opportunity object provided under the heading of "​Building a Custom List Controller" in Visualforce Developer Guide. I think there are some issues.
Amit Chaudhary 8Amit Chaudhary 8
Please try below code. I hope that will work. Please pass query as String
public class InnovationOrderingController {
//ApexPages.StandardSetController must be instantiated
//For standard list controllers
	
    public ApexPages.StandardSetController orderdets {
        get{
        if(orderdets == null) {
				
				
            orderdets = new ApexPages.StandardSetController(Database.getQueryLocater('SELECT  Additional_Comments__c,Construction_Type__c,Contract_Signed_Date__c,CSA_ID__c,customer_site_id__c,Location_ID__c,Order_Completion_Date__c,Order_Status__c,Order_Type__c, Product_Instance_Number__c, Requested_Speed__c, Requested_Start_Date__c, Service_Status__c, site_name__c FROM innovation_orders__c' ));
    }
    return orderdets;
    }
    set;
    }
//Initalize orderdets and return a list of records
    public List<innovation_orders__c> getOrderDets() {
        return (List<innovation_orders__c>) orderdets.getRecords();
    }
}

Please let us know if this will help you
ProlayProlay
Did not work for me
AshlekhAshlekh
Hi Prolay,

What issue you are facing?

-thanks
Ashlekh Gera
ProlayProlay
The same error which is mentioned by @geoff. The method does not exist or wrong signature
Richard TuttleRichard Tuttle
That usage in your original example is valid according to the Database class documentation.  This usually means someone has created a class in your organization called Database (seen usually with Test class).  Check to see if this is the case, if so, rename or delete it.

--Richard
ProlayProlay
Richard, this is not in my case.
Richard TuttleRichard Tuttle
Oh hah, this one should have slapped me in the face.  The method name is getQueryLocator (note the o instead of an e).  That should solve your problem.

--Richard
This was selected as the best answer
ProlayProlay
Me too Richard :). Solved!
Geoff SpozettaGeoff Spozetta

Thanks Richard, you're a life saver :)


Regards,

Geoff SpozettaGeoff Spozetta
Hi richard,  Not sure if you'd be able to help further, I've altered the code as per your recommendation, and I'm running into this issue now:
 
Error: Unknown property 'ApexPages.StandardSetController.Location_ID__c'

Page currently looks like this and the controller has not been altered from my first post:
 
<apex:page controller="InnovationOrderingController">
    <apex:pageBlock title = "Congration">
        <apex:pageblockSection columns="1">
        
            <apex:pageBlockTable value="{!orderdets}" var="order" >
                <apex:datalist var="o" value="{!order.Location_ID__c}"/>
                
            </apex:pageBlockTable>
        </apex:pageblockSection>
        
    </apex:pageBlock>
</apex:page>

Cheers,

Geoff
 
Richard TuttleRichard Tuttle
The orderdets is an instance of StandardSetController.  To reach the actual list of data you'll have to use the .getRecords() method.  I put a sample below, but I'm not positive it exposes the getter method like this (some system methods do, others don't).  If this code doesn't work, you'll need to create your own getter method in the controller to expose the List<innovation_orders__c>.
<apex:page controller="InnovationOrderingController">
    <apex:pageBlock title = "Congration">
        <apex:pageblockSection columns="1">
        
            <apex:pageBlockTable value="{!orderdets.Records}" var="order" >
                <apex:datalist var="o" value="{!order.Location_ID__c}"/>
                
            </apex:pageBlockTable>
        </apex:pageblockSection>
        
    </apex:pageBlock>
</apex:page>

If that doesn't work, expose it like this:
public List<innovation_orders__c> getOrders() {
    return (List<innovation_orders__c>) orderdets.getRecords();
}
Then iterate {!Orders} in your pageBlockTable.

Hope that helps.


 
Geoff SpozettaGeoff Spozetta
Thanks Richard, Got it!