function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Robert Goldberg 9Robert Goldberg 9 

Constructor Issue with List - Will Not Compile

I have a Visualforce search page with a wrapper class, where I want to take the selected results, add them to a list, and then have that list passed to another page.  I cannot compile my current class, which drives the page.  Here's the class:

public with sharing class AllOppsearchClass
{
    public List<Lead> leadList {get; set;}
    public Set<Lead> leadsel {get; set;}
    public List<Opportunity> optyList {get; set;}
    public list<Opportunity> optysel {get; set;}
    public String searchStr {get; set;}


    // lists for the results
    public List<LeadResultWrapper> leadResults {get; set;}
    public List<OpportunityResultWrapper> opportunityResults {get; set;}

    public AllOppsearchClass()
    {

    }
    public void UpdateLeadRouterCommentsLead()
    {

    }
    public void UpdateLeadRouterCommentsOpp()
    {
      
    }
    public AllOppsearchClass(ApexPages.StandardController stdController)
    { }
 
    public void soslDemo_method()
    {
        leadList = New List<Lead>();
        optyList = New List<Opportunity>();

        // instantiate the result lists
        leadResults = new List<LeadResultWrapper>();
        opportunityResults = new List<OpportunityResultWrapper>();

        if(searchStr.length() > 1)
        {
            String searchStr1 = '*'+searchStr+'*';
            String searchQuery = 'FIND \'' + searchStr1 + '\' IN ALL FIELDS RETURNING  Lead (Id,Name,Email,Owner_Name__c,metro__c,Last_Comment__c,statusname__c,Listing_MLS__c,last_update_date__c,date_entered_into_Lead_router__c,listing_amount__c,listing_agent__c,Listing_Area__c,referral_fee__c,Current_Source__c,Lead_Router_ID__c,Status,Routing_Group__c,Comments_Notes__c,last_activity_subject__c,Potential_Duplicate__c),Opportunity(Id,Name,Account_Email__c,StageName,Opportunity_EMail__c,metro__c,Last_Comment__c,statusname__c,Owner_Name__c,last_update_date__c,date_entered_into_Lead_router__c,Current_Source__c,Listing_Area__c,Comments_Notes__c,listing_amount__c,listing_agent__c,Lead_Router_ID__c,Routing_Group__c,agent__c,Listing_MLS__c,referral_fee__c,last_activity_subject__c,Potential_Duplicate__c)';
            List<List <sObject>> searchList = search.query(searchQuery);
            leadList = ((List<Lead>)searchList[0]);
            optyList = ((List<Opportunity>)searchList[1]);
            if(leadList.size() == 0 && optyList.size() == 0)
            {
                apexPages.addmessage(new apexpages.message(apexpages.severity.Error, 'Sorry, no results returned with matching string..'));
                return;
            }

            // take the contents of the object lists and add them into the result wrapper lists
            for (Lead l : leadList) leadResults.add(new LeadResultWrapper(l));
            for (Opportunity o : optyList) opportunityResults.add(new OpportunityResultWrapper(o));
        }
        else
        {
            apexPages.addmessage(new apexpages.message(apexpages.severity.Error, 'Please enter at least two characters..'));
            return;
        }
    }

    // to take action on selected leads

    public class LeadResultWrapper
    {
        public Lead l {get; set;}
        public Boolean selectedEh {get; set;}

        public LeadResultWrapper(Lead lIn)
        {
            // assign the record from the inital sosl query row and set checkbox option to FALSE
            l = lIn;
            selectedEh = FALSE;
        }
    }
    public PageReference doSomethingWithLeads()
    {
        for (LeadResultWrapper l : leadResults) // loop through all lead records in search results
        {
            //List<String> leadselec = New List <String>();
            if(l.selectedEh=TRUE) {leadsel.addAll(leadList);}
            List<Lead> leadselec = [SELECT Id FROM Lead WHERE Id In:leadsel];

            {
            ApexPages.StandardController controller = new ApexPages.StandardController(leadselec);
            PageReference MassLRCommentLead = new ApexPages.StandardController(leadselec).view();
            MassLRCommentLead.setRedirect(true);
            return MassLRCommentLead;
            }
        }

        return null;
    }

    public class OpportunityResultWrapper
    {
        public Opportunity o {get; set;}
        public Boolean selectedEh {get; set;}

        public OpportunityResultWrapper(Opportunity oIn)
        {
            // assign the record from the inital sosl query row and set checkbox option to FALSE
            o = oIn;
            selectedEh = FALSE;
        }
    }
        // to take action on selected opportunities
    public PageReference doSomethingWithOpportunities()
    {
        for (OpportunityResultWrapper o : opportunityResults) // loop through all opportunity records in search results
        {
             if(o.selectedEH=TRUE) {optysel.addall(optyList);}
            //PageReference MassLRComment = new ApexPages.StandardController(opportunityResults).view();
            //MassLRComment.setRedirect(true);
            //return MassLRComment;
        }

        return null;
    }

}

And the page:

<apex:page controller="AllOppsearchClass">
    <apex:form >
        <apex:inputtext value="{!searchStr}"></apex:inputtext>
        <apex:commandbutton value="Search in Lead, Opportunity" action="{!soslDemo_method}" rerender="lead,error,oppt" status="actStatusId"></apex:commandbutton>
        <apex:actionstatus id="actStatusId">
        <apex:facet name="start">
            <img src="/img/loading.gif"/>                    
                </apex:facet>
        </apex:actionstatus>
    </apex:form>

 
    <apex:outputpanel title="" id="error">
        <apex:pagemessages ></apex:pagemessages>
    </apex:outputpanel>

    <!-- opportunity results; note that because we've placed the Opportunity record inside of the wrapper, we call down the object hierarchy -->
    <apex:pageblock title="Opportunities" id="oppt">
        <!-- buttons to take action on opportunity results selected -->
        <apex:form >
        <apex:commandButton action="{!URLFOR($Page.MassLRComment, null)}" id="editButton" value="Update Status & Comments" />
</apex:form>
        <apex:pageblocktable value="{!opportunityResults}" var="opty">
            <!-- add a column for each checkbox field -->
            <apex:column >
                <apex:form >
                <apex:inputcheckbox value="{!opty.selectedEh}"></apex:inputcheckbox></apex:form>
            </apex:column>            
            <apex:column value="{!opty.o.Date_Entered_Into_Lead_Router__c}"></apex:column>
            <apex:column value="{!opty.o.Metro__c}"></apex:column>
            <apex:column headervalue="Name"><apex:outputlink value="/{!opty.o.ID}" target="_blank">{!opty.o.Name}</apex:outputlink></apex:column>
            <apex:column value="{!opty.o.Lead_Router_ID__c}"></apex:column>
            <apex:column value="{!opty.o.StageName}"></apex:column>
            <apex:column value="{!opty.o.Agent__c}"></apex:column>     
            <apex:column value="{!opty.o.Account_Email__c}"></apex:column>
            <apex:column value="{!opty.o.Current_Source__c}"></apex:column>
            <apex:column value="{!opty.o.Referral_Fee__c}"></apex:column>
            <apex:column value="{!opty.o.Listing_Agent__c}"></apex:column>
            <apex:column value="{!opty.o.Listing_Area__c}"></apex:column>
            <apex:column value="{!opty.o.Listing_Amount__c}"></apex:column>
            <apex:column value="{!opty.o.Listing_MLS__c}"></apex:column>
            <apex:column value="{!opty.o.Comments_Notes__c}"></apex:column>
            <apex:column value="{!opty.o.Potential_Duplicate__c}"></apex:column>

        </apex:pageblocktable>
    </apex:pageblock>
 
    <!-- lead results; note that because we've placed the Lead record inside of the wrapper, we call down the object hierarchy -->
    <apex:pageblock title="Leads" id="lead">
        <!-- buttons to take action on lead results selected -->
<apex:form >
        <apex:commandButton action="{!URLFOR($Page.MassLRCommentLead, null)}" id="editButton" value="Update Status & Comments" />
</apex:form>
        <apex:pageblocktable value="{!leadResults}" var="lead">
            <!-- add a column for checkbox field -->
            <apex:column ><apex:form >
                <apex:inputcheckbox value="{!lead.selectedEh}"></apex:inputcheckbox>
</apex:form>
            </apex:column>            

            <apex:column value="{!lead.l.Date_Entered_Into_Lead_Router__c}"></apex:column>
            <apex:column value="{!lead.l.Metro__c}"></apex:column>
            <apex:column headervalue="Name"><apex:outputlink value="/{!lead.l.ID}" target="_blank">{!lead.l.Name}</apex:outputlink></apex:column>
            <apex:column value="{!lead.l.Lead_Router_ID__c}"></apex:column>
            <apex:column value="{!lead.l.Status}"></apex:column>
            <apex:column value="{!lead.l.Routing_Group__c}"></apex:column>
            <apex:column value="{!lead.l.email}"></apex:column>
            <apex:column value="{!lead.l.Current_Source__c}"></apex:column>
            <apex:column value="{!lead.l.Referral_Fee__c}"></apex:column>
            <apex:column value="{!lead.l.Listing_Agent__c}"></apex:column>
            <apex:column value="{!lead.l.Listing_Area__c}"></apex:column>
            <apex:column value="{!lead.l.Listing_Amount__c}"></apex:column>
            <apex:column value="{!lead.l.Listing_MLS__c}"></apex:column>
            <apex:column value="{!lead.l.Comments_Notes__c}"></apex:column>
            <apex:column value="{!lead.l.Potential_Duplicate__c}"></apex:column>                                                
                        
        </apex:pageblocktable>
    </apex:pageblock>
</apex:page>
Robert Goldberg 9Robert Goldberg 9
I'm getting this error: Constructor not defined: [ApexPages.StandardController].<Constructor>(List<Lead>)

Related to: ApexPages.StandardController controller = new ApexPages.StandardController(leadselec);
v varaprasadv varaprasad
Hi Robert,

Remove following line and check once.

 public AllOppsearchClass(ApexPages.StandardController stdController)
    { }


Hope this helps you!

Thanks
Varaprasad
@For Support: varaprasad4sfdc@gmail.com

 
Robert Goldberg 9Robert Goldberg 9
I removed the lines - no change.  Same compiling issue with the constructor.