I am preparing for the PD1 exam and I was practicing an example on the standard list controllers using extension. The extension class limits the opportunity to show only 2 records but it is showing more than 2 records. Can someone help me to understand where I am going wrong and how the setController.setSelected method works?

Extension Class

public  class accExtension {
public ApexPages.StandardSetController setController;
public accExtension(ApexPages.StandardSetController setController) {
    this.setController = setController;
    Opportunity [] records = [SELECT Id, Name FROM Opportunity LIMIT 2];

Visualforce page

<apex:page standardController="Opportunity" recordSetVar="opps" extensions="accExtension">
    <apex:pageBlockTable value="{!opps}" var="acc">
        <apex:column value="{!acc.Name}"/>
        <apex:column value="{!acc.StageName}"/>
  • Your answer will come from Chapter 4 of VF in Practice - in particular, the section entitled Advanced Filtering—Using Standard Set Controllers Inside Custom Controllers.
    – cropredy
    Dec 12, 2020 at 4:42
  • Thanks @cropredy Appreciate it! Dec 12, 2020 at 6:29

1 Answer 1


Salesforce Documentation for setSelected --> https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_sosc_access_data.htm


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .