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 

How do I add a wrapper class (and buttons) to this controller?

I have a working Visualforce page and controller, that searches both Leads & Opportunities for a specific email address, and displays fields if there are any results.

I have been asked by our business department to make a change, adding checkboxes and radio buttons to the page.

I have no idea how I might begin doing this.  Does anyone have any ideas?

Here is the controller:

Public with sharing class AllOppsearchClass{
 Public List<Lead>leadList{get;set;}
 Public List<Opportunity>optyList{get;set;}
   Public String searchStr{get;set;}
   Public AllOppsearchClass(){
   }
     public AllOppsearchClass(ApexPages.StandardController stdController){}
 
    Public void soslDemo_method(){
       leadList = New List<Lead>();
   optyList = New List<Opportunity>();

        
   
   if(searchStr.length() > 1){
   String searchStr1 = '*'+searchStr+'*';
   String searchQuery = 'FIND \'' + searchStr1 + '\' IN ALL FIELDS RETURNING  Lead (Id,Name,Owner_Name__c,Email,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,referral_fee__c,last_activity_subject__c),Opportunity(Id,Name,Account_Email__c,Opportunity_EMail__c,metro__c,Last_Comment__c,statusname__c,Owner_Name__c,last_update_date__c,date_entered_into_Lead_router__c,listing_amount__c,listing_agent__c,agent__c,referral_fee__c,last_activity_subject__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;
   }
   }
   else{
   apexPages.addmessage(new apexpages.message(apexpages.severity.Error, 'Please enter at least two characters..'));
   return;
   }
  }
}

And the Visualforce page:

<apex:page standardcontroller="Lead" extensions="AllOppsearchClass">
  <apex:form >
  <apex:inputText value="{!searchStr}"/>
    <apex:commandButton value="Search in Lead, Opportunity" action="{!soslDemo_method}"                reRender="lead,error,oppt" status="actStatusId"/>
    <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>

     <apex:pageBlock title="Opportunities" id="oppt">
    <apex:pageblockTable value="{!optyList}" var="opty">
     <apex:column headervalue="Name"><apex:outputLink value="/{!opty.ID}" target="_blank">{!opty.name}</apex:outputLink></apex:column>
     <apex:column value="{!opty.Account_Email__c}"/>
     <apex:column value="{!opty.Metro__c}"/>
     <apex:column value="{!opty.Owner_Name__c}"/>
     <apex:column value="{!opty.StatusName__c}"/>
     <apex:column value="{!opty.Date_Entered_Into_Lead_Router__c}"/>
     <apex:column value="{!opty.Last_Update_Date__c}"/>     
     <apex:column value="{!opty.Listing_Amount__c}"/>
     <apex:column value="{!opty.Listing_Agent__c}"/>
     <apex:column value="{!opty.Agent__c}"/>
     <apex:column value="{!opty.Referral_Fee__c}"/>
     <apex:column value="{!opty.Last_Comment__c}"/>


       </apex:pageblockTable>
    </apex:pageBlock>
 
    <apex:pageBlock title="Leads" id="lead">
    <apex:pageblockTable value="{!leadList }" var="lead">
     <apex:column headervalue="Name"><apex:outputLink value="/{!lead.ID}" target="_blank">{!lead.name}</apex:outputLink></apex:column>
     <apex:column value="{!lead.email}"/>
     <apex:column value="{!lead.Metro__c}"/>
     <apex:column value="{!lead.Owner_Name__c}"/>
     <apex:column value="{!lead.StatusName__c}"/>
     <apex:column value="{!lead.Date_Entered_Into_Lead_Router__c}"/>
     <apex:column value="{!lead.Last_Update_Date__c}"/>
     <apex:column value="{!lead.Listing_Amount__c}"/>
     <apex:column value="{!lead.Listing_MLS__c}"/>
     <apex:column value="{!lead.Listing_Agent__c}"/>
     <apex:column value="{!lead.Referral_Fee__c}"/>
     <apex:column value="{!lead.Last_Comment__c}"/>


 </apex:pageblockTable>
    </apex:pageBlock>
</apex:page>
Joe BrodarJoe Brodar

Hi Robert!

I've taken a crack at what I think you need. It was a little hard to tell from your description, but I think what you were saying you need is to add checkbox options and radio select options to each row that is returned? (If this is information that needs to be saved, then instead of using a wrapper class, you will need to add them as fields on the objects, which you can then call as normal.) 

I've commented in each place where I've added something your originals:

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

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

  	// a list for each set of radio button options you need
 	public List<SelectOption> radioOptions {get; set;}
 	public List<SelectOption> radioOptions2 {get; set;}

  	public AllOppsearchClass()
  	{ 
  		// call the function to set the options for the radio buttons on page load
  		setRadioOptions();
  	}

	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,Owner_Name__c,Email,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,referral_fee__c,last_activity_subject__c),Opportunity(Id,Name,Account_Email__c,Opportunity_EMail__c,metro__c,Last_Comment__c,statusname__c,Owner_Name__c,last_update_date__c,date_entered_into_Lead_router__c,listing_amount__c,listing_agent__c,agent__c,referral_fee__c,last_activity_subject__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;
  		}
	}

	private void setRadioOptions()
	{
		// instantiate the first radio option set, and fill with options
		radioOptions = new List<SelectOption>();
		radioOptions.add(new SelectOption('Option Value 1','Option Label 1'));
		radioOptions.add(new SelectOption('Option Value 2','Option Label 2'));

		// instantiate the second radio option set, and fill with options
		radioOptions2 = new List<SelectOption>();
		radioOptions2.add(new SelectOption('Option Value 1','Option Label 1'));
		radioOptions2.add(new SelectOption('Option Value 2','Option Label 2'));
	}

  	public class LeadResultWrapper
  	{
    	public Lead l {get; set;}
    	// a boolean variable for each checkbox item you need
    	public Boolean checkboxOption {get; set;}
    	public Boolean checkboxOption2 {get; set;}
    	// a string variable for each radio select option set
    	public String radioOption {get; set;}
    	public String radioOption2 {get; set;}

    	public LeadResultWrapper(Lead lIn)
    	{ 
    		// assign the record from the inital sosl query row and set checkbox options to FALSE
    		l = lIn; 
    		checkboxOption = checkboxOption2 = FALSE;
    	}
  	}

    public class OpportunityResultWrapper
    {
        public Opportunity o {get; set;}
    	// a boolean variable for each checkbox item you need
    	public Boolean checkboxOption {get; set;}
    	public Boolean checkboxOption2 {get; set;}
    	// a string variable for each radio select option set
    	public String radioOption {get; set;}
    	public String radioOption2 {get; set;}

        public OpportunityResultWrapper(Opportunity oIn)
    	{ 
    		// assign the record from the inital sosl query row and set checkbox options to FALSE
    		o = oIn;
    		checkboxOption = checkboxOption2 = FALSE;
    	}
  	}
}


In the controller, what I've done is create a separate wrapper class for each object type, then filled a list of each using the results returned by your SOSL query. In the wrapper classes, I have a property for the main record that is being accessed, as well as Boolean properties for the checkbox fields and String properties for the radio select fields. I created two of each kind, but you can replicate for as many as you need. For the radio options, I created a list of SelectOption records for each field that you need (again, I created two, but you can replicate as many as needed).
 
<apex:page standardcontroller="Lead" extensions="AllOppsearchClass">
    <apex:form >
        <apex:inputText value="{!searchStr}"/>
        <apex:commandButton value="Search in Lead, Opportunity" action="{!soslDemo_method}" reRender="lead,error,oppt" status="actStatusId" />
        <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">
        <apex:pageblockTable value="{!opportunityResults}" var="opty">
            <apex:column headervalue="Name">
                <apex:outputLink value="/{!opty.ID}" target="_blank">{!opty.name}</apex:outputLink>
            </apex:column>
            <apex:column value="{!opty.o.Account_Email__c}"/>
            <apex:column value="{!opty.o.Metro__c}"/>
            <apex:column value="{!opty.o.Owner_Name__c}"/>
            <apex:column value="{!opty.o.StatusName__c}"/>
            <apex:column value="{!opty.o.Date_Entered_Into_Lead_Router__c}"/>
            <apex:column value="{!opty.o.Last_Update_Date__c}"/>     
            <apex:column value="{!opty.o.Listing_Amount__c}"/>
            <apex:column value="{!opty.o.Listing_Agent__c}"/>
            <apex:column value="{!opty.o.Agent__c}"/>
            <apex:column value="{!opty.o.Referral_Fee__c}"/>
            <apex:column value="{!opty.o.Last_Comment__c}"/>

            <!-- add a column for each radio option field -->
            <apex:column>
                <apex:selectRadio value="{opty.radioOption}">
                    <apex:selectOptions value="{radioOptions}" />
                </apex:selectRadio>
            </apex:column>
            <apex:column>
                <apex:selectRadio value="{opty.radioOption2}">
                    <apex:selectOptions value="{radioOptions2}" />
                </apex:selectRadio>
            </apex:column>
            <!-- add a column for each checkbox option field -->
            <apex:column>
                <apex:inputCheckbox value="{!opty.checkboxOption}" />
            </apex:column>
            <apex:column>
                <apex:inputCheckbox value="{!opty.checkboxOption2}" />
            </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">
        <apex:pageblockTable value="{!leadResults}" var="lead">
            <apex:column headervalue="Name">
                <apex:outputLink value="/{!lead.ID}" target="_blank">{!lead.name}</apex:outputLink>
            </apex:column>
            <apex:column value="{!lead.l.email}"/>
            <apex:column value="{!lead.l.Metro__c}"/>
            <apex:column value="{!lead.l.Owner_Name__c}"/>
            <apex:column value="{!lead.l.StatusName__c}"/>
            <apex:column value="{!lead.l.Date_Entered_Into_Lead_Router__c}"/>
            <apex:column value="{!lead.l.Last_Update_Date__c}"/>
            <apex:column value="{!lead.l.Listing_Amount__c}"/>
            <apex:column value="{!lead.l.Listing_MLS__c}"/>
            <apex:column value="{!lead.l.Listing_Agent__c}"/>
            <apex:column value="{!lead.l.Referral_Fee__c}"/>
            <apex:column value="{!lead.l.Last_Comment__c}"/>

            <!-- add a column for each radio option field -->
            <apex:column>
                <apex:selectRadio value="{lead.radioOption}">
                    <apex:selectOptions value="{radioOptions}" />
                </apex:selectRadio>
            </apex:column>
            <apex:column>
                <apex:selectRadio value="{lead.radioOption2}">
                    <apex:selectOptions value="{radioOptions2}" />
                </apex:selectRadio>
            </apex:column>
            <!-- add a column for each checkbox option field -->
            <apex:column>
                <apex:inputCheckbox value="{!opty.checkboxOption}" />
            </apex:column>
            <apex:column>
                <apex:inputCheckbox value="{!opty.checkboxOption2}" />
            </apex:column>
        </apex:pageblockTable>
    </apex:pageBlock>
</apex:page>
In the Visualforce page, I have just switched the data tables to use the wrapper lists instead of the direct lists that you have, and then added columns for each of the checkbox and radio select options.

Since I am not sure what the checkbox and radio select fields would be for, I didn't add any methods or anything using them, but you can then access those values from Apex methods as long as the page is loaded (because they are not actually saved to Lead or Opportunity records, they are not persistent values; see my comment at the beginning).

Let me know if that is helpful!

- Joe Brodar

 
Joe BrodarJoe Brodar
Hey Robert, 

I realized I did not update the Name column fields in either of the data tables. Instead of {!lead.ID} it should be {!lead.l.ID} and {!lead.l.Name}, etc because we need to call down the wrapper hierarchy. If you are getting a Visualforce error, that is probably why.

- Joe
Robert Goldberg 9Robert Goldberg 9
Joe,

Thanks so much for your updates - it took me a while to get through this, but I think I actually did a bad job of what I'm really looking for.

The Visualforce page should be a search.  I want to be able to use the search function, and then be able to use checkboxes next to the results, and then click list action buttons to perform actions against those items I have checked, not radio buttons.  Sorry about that - bad descriptor on my part.  I can't seem to get the Visualforce page to work as you have it here - and I'm not sure why.

Thanks,

Robert
Joe BrodarJoe Brodar

Hi Robert!

Thank you for the clarification, I think my ammended code below should allow you to do the following:

  1. Search for Leads & Opportunities
  2. Display a checkbox next to each result in the tables
  3. Select the checkboxes next to each record that you want to take action on
  4. Click a button above the table, which will complete an action for each record you selected
In the Apex class, I removed the portions that were about the radio options, and added a method for an action on each record type:
public with sharing class AllOppsearchClass
{
    public List<Lead> leadList {get; set;}
    public List<Opportunity> optyList {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 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,Owner_Name__c,Email,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,referral_fee__c,last_activity_subject__c),Opportunity(Id,Name,Account_Email__c,Opportunity_EMail__c,metro__c,Last_Comment__c,statusname__c,Owner_Name__c,last_update_date__c,date_entered_into_Lead_router__c,listing_amount__c,listing_agent__c,agent__c,referral_fee__c,last_activity_subject__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 opportunities
    public PageReference doSomethingWithOpportunities()
    {
        for (OpportunityResultWrapper o : opportunityResults) // loop through all opportunity records in search results
        {
            if (o.selectedEh) // if you checked the box on the vf page
            {
                // perform actions here
            }
        }

        return null;
    }

    // to take action on selected leads
    public PageReference doSomethingWithLeads()
    {
        for (LeadResultWrapper l : leadResults) // loop through all lead records in search results
        {
            if (l.selectedEh) // if you checked the box on the vf page
            {
                // perform actions here
            }
        }

        return null;
    }

	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 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;
      	}
	}
}

Then in the VF page, I removed the extra columns for the radio options and the extra checkbox, as well as adding an example action button above each results table:
<apex:page standardcontroller="Lead" extensions="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">
<a class="sw-phone" title="Call with Dialpad" target="_blank" href="https://dialpad.com/launch?phone=%20%20%20%20%20%20%20%20%20%20%20%20%20%20" rel="nofollow">              </a>  <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:commandButton action="{!doSomethingWithOpportunities}" value="Opportunity Action" />

        <apex:pageblocktable value="{!opportunityResults}" var="opty">
            <apex:column headervalue="Name">
                <apex:outputlink value="/{!opty.o.ID}" target="_blank">{!opty.o.Name}</apex:outputlink>
            </apex:column>
            <apex:column value="{!opty.o.Account_Email__c}"></apex:column>
            <apex:column value="{!opty.o.Metro__c}"></apex:column>
            <apex:column value="{!opty.o.Owner_Name__c}"></apex:column>
            <apex:column value="{!opty.o.StatusName__c}"></apex:column>
            <apex:column value="{!opty.o.Date_Entered_Into_Lead_Router__c}"></apex:column>
            <apex:column value="{!opty.o.Last_Update_Date__c}"></apex:column>     
            <apex:column value="{!opty.o.Listing_Amount__c}"></apex:column>
            <apex:column value="{!opty.o.Listing_Agent__c}"></apex:column>
            <apex:column value="{!opty.o.Agent__c}"></apex:column>
            <apex:column value="{!opty.o.Referral_Fee__c}"></apex:column>
            <apex:column value="{!opty.o.Last_Comment__c}"></apex:column>

            <!-- add a column for each checkbox field -->
            <apex:column>
                <apex:inputcheckbox value="{!opty.selectedEh}"></apex:inputcheckbox>
            </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:commandButton action="{!doSomethingWithLeads}" value="Lead Action" />

        <apex:pageblocktable value="{!leadResults}" var="lead">
            <apex:column headervalue="Name">
                <apex:outputlink value="/{!lead.l.ID}" target="_blank">{!lead.l.Name}</apex:outputlink>
            </apex:column>
            <apex:column value="{!lead.l.email}"></apex:column>
            <apex:column value="{!lead.l.Metro__c}"></apex:column>
            <apex:column value="{!lead.l.Owner_Name__c}"></apex:column>
            <apex:column value="{!lead.l.StatusName__c}"></apex:column>
            <apex:column value="{!lead.l.Date_Entered_Into_Lead_Router__c}"></apex:column>
            <apex:column value="{!lead.l.Last_Update_Date__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.Listing_Agent__c}"></apex:column>
            <apex:column value="{!lead.l.Referral_Fee__c}"></apex:column>
            <apex:column value="{!lead.l.Last_Comment__c}"></apex:column>

            <!-- add a column for checkbox field -->
            <apex:column>
                <apex:inputcheckbox value="{!lead.selectedEh}"></apex:inputcheckbox>
            </apex:column>
        </apex:pageblocktable>
    </apex:pageblock>
</apex:page>


Let me know if that more accurately reflects what you are going for! 

- Joe

Joe BrodarJoe Brodar
It looks like I had an issue with a browser extension when copy-pasting code in my last response. Here's the VF page code without the weird Dialpad link insertion:
<apex:page standardcontroller="Lead" extensions="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: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:commandButton action="{!doSomethingWithOpportunities}" value="Opportunity Action" />

        <apex:pageblocktable value="{!opportunityResults}" var="opty">
            <apex:column headervalue="Name">
                <apex:outputlink value="/{!opty.o.ID}" target="_blank">{!opty.o.Name}</apex:outputlink>
            </apex:column>
            <apex:column value="{!opty.o.Account_Email__c}"></apex:column>
            <apex:column value="{!opty.o.Metro__c}"></apex:column>
            <apex:column value="{!opty.o.Owner_Name__c}"></apex:column>
            <apex:column value="{!opty.o.StatusName__c}"></apex:column>
            <apex:column value="{!opty.o.Date_Entered_Into_Lead_Router__c}"></apex:column>
            <apex:column value="{!opty.o.Last_Update_Date__c}"></apex:column>     
            <apex:column value="{!opty.o.Listing_Amount__c}"></apex:column>
            <apex:column value="{!opty.o.Listing_Agent__c}"></apex:column>
            <apex:column value="{!opty.o.Agent__c}"></apex:column>
            <apex:column value="{!opty.o.Referral_Fee__c}"></apex:column>
            <apex:column value="{!opty.o.Last_Comment__c}"></apex:column>

            <!-- add a column for each checkbox field -->
            <apex:column>
                <apex:inputcheckbox value="{!opty.selectedEh}"></apex:inputcheckbox>
            </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:commandButton action="{!doSomethingWithLeads}" value="Lead Action" />

        <apex:pageblocktable value="{!leadResults}" var="lead">
            <apex:column headervalue="Name">
                <apex:outputlink value="/{!lead.l.ID}" target="_blank">{!lead.l.Name}</apex:outputlink>
            </apex:column>
            <apex:column value="{!lead.l.email}"></apex:column>
            <apex:column value="{!lead.l.Metro__c}"></apex:column>
            <apex:column value="{!lead.l.Owner_Name__c}"></apex:column>
            <apex:column value="{!lead.l.StatusName__c}"></apex:column>
            <apex:column value="{!lead.l.Date_Entered_Into_Lead_Router__c}"></apex:column>
            <apex:column value="{!lead.l.Last_Update_Date__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.Listing_Agent__c}"></apex:column>
            <apex:column value="{!lead.l.Referral_Fee__c}"></apex:column>
            <apex:column value="{!lead.l.Last_Comment__c}"></apex:column>

            <!-- add a column for checkbox field -->
            <apex:column>
                <apex:inputcheckbox value="{!lead.selectedEh}"></apex:inputcheckbox>
            </apex:column>
        </apex:pageblocktable>
    </apex:pageblock>
</apex:page>

- Joe
Robert Goldberg 9Robert Goldberg 9
Joe,

Thanks very much - I think it's almost there.  The class looks good, and after I made a couple of cosmetic changes to the page, it is generating and giving me the ability to show the checkmarks, which is great!  I did have to make the class the controller, dropping the StandardController of Lead - it wouldn't save otherwise.

The real issue is that I can't seem to actually generate the buttons - no matter what values I choose for those buttons, it's giving me an error.  So, if they're blank, it saves, but otherwise, it won't.

Here's what I have now:

And, ideally, I'd like to add buttons that are:
"Closed - Trash" (Closed_Trash)
"Closed - Cold" (Closed_Cold)
"Update Lead Router Comments" (Update_Lead_Router_Comments)

To both Opportunities & Leads.
<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="{!}" value="" />
</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 headervalue="Name">
                <apex:outputlink value="/{!opty.o.ID}" target="_blank">{!opty.o.Name}</apex:outputlink>
            </apex:column>
            <apex:column value="{!opty.o.Account_Email__c}"></apex:column>
            <apex:column value="{!opty.o.Metro__c}"></apex:column>
            <apex:column value="{!opty.o.Owner_Name__c}"></apex:column>
            <apex:column value="{!opty.o.StatusName__c}"></apex:column>
            <apex:column value="{!opty.o.Date_Entered_Into_Lead_Router__c}"></apex:column>
            <apex:column value="{!opty.o.Last_Update_Date__c}"></apex:column>     
            <apex:column value="{!opty.o.Listing_Amount__c}"></apex:column>
            <apex:column value="{!opty.o.Listing_Agent__c}"></apex:column>
            <apex:column value="{!opty.o.Agent__c}"></apex:column>
            <apex:column value="{!opty.o.Referral_Fee__c}"></apex:column>
            <apex:column value="{!opty.o.Last_Comment__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="{!}" value="" />
    <apex:commandButton action="{!}" value="" />
</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 headervalue="Name">
            <apex:outputlink value="/{!lead.l.ID}" target="_blank">{!lead.l.Name}</apex:outputlink>
            </apex:column><apex:column value="{!lead.l.email}"></apex:column>
            <apex:column value="{!lead.l.Metro__c}"></apex:column>
            <apex:column value="{!lead.l.Owner_Name__c}"></apex:column>
            <apex:column value="{!lead.l.StatusName__c}"></apex:column>
            <apex:column value="{!lead.l.Date_Entered_Into_Lead_Router__c}"></apex:column>
            <apex:column value="{!lead.l.Last_Update_Date__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.Listing_Agent__c}"></apex:column>
            <apex:column value="{!lead.l.Referral_Fee__c}"></apex:column>
            <apex:column value="{!lead.l.Last_Comment__c}"></apex:column>


        </apex:pageblocktable>
    </apex:pageblock>
</apex:page>