3

To minimize the complexity and number of distinct pages in my org I would like to use a single VF page to override both the standard Delete action and create a Delete list view action that allows a group of deletions. Can I accomplish this by using a single page with two constructors like this?

public ForecastSubmissionExtension(ApexPages.StandardController stdController) {
  this.forecastSubmissions = new ForecastSubmission__c[]{
    (ForecastSubmission__c)stdController.getRecord()};
}

public ForecastSubmissionExtension(ApexPages.StandardSetController controller) {
  this.forecastSubmissions = controller.getSelected();
}
3

It is not possible for a single VF page to do this, but you can create 2 VF pages and have them use the same controller extension, using the same notation you used above.

Single Record Handler

<apex:page standardController="ForecastSubmission__c" 
  extensions="ForecastSubmissionExtension" 
  action="{!softDeleteRecord}">
  ...
</apex:page>

List Handler

<apex:page standardController="ForecastSubmission__c"     
  extensions="ForecastSubmissionExtension" recordSetVar="submissions" 
  action={!softDeleteRecord}">
....
</apex:page>
0

You might not be able to use 'recordSetVar' for pagination but you could override both Standard controller and StandardSet controller functionality in the code and use Javascript to select the records from the list and act upon them. For one of my projects, I had to create a new button on the standard page and display a list of the object values with the option of update/deletion on them.

<apex:page standardController="Company__c" extensions="CompCtrl" >
...
...



 <apex:pageBlockTable id="pgblktbl" width="60" value="{!OrderList}" var="o">
<apex:column width="25px">

<apex:inputCheckbox id="inpchk" value="{!o.selected}"> <apex:actionSupport event="onchange" action="{!getInvWrapper}" rerender="pgInvBlk,theGrid11"> <apex:param value="{!o.mo.Id}" name="par1" assignTo="{!moIdSel}" /> </apex:actionSupport> </apex:inputCheckbox> .....
..... `Controller Snippet: public CompCtrl(ApexPages.StandardController controller) { compId = controller.getRecord().id;

    }`
public ApexPages.StandardSetController con 
    {
    String soql = 'SELECT Name,OrderDescription__c,Status__c,CompletionDate__c,AmountPaid__c FROM MissionOrder__c WHERE Company__c=\''+compId +'\' order by '+sortByVal;
con = new ApexPages.StandardSetController(Database.getQueryLocator(soql));
                con.setPageSize(noRecs);
            }
        }
        return con;
        }
        private set;
    }
public List< MOWrapper > getOrderList() 
    {
        moWrappers = new List<MOWrapper>();
        for (MissionOrder__c mo : (List<MissionOrder__c>)con.getRecords())
        {
            if(moIdSet.size()>0 && moIdSet.contains(mo.Id))
                moWrappers.add(new MOWrapper(mo, true));
            else
                moWrappers.add(new MOWrapper(mo));
        }
        return moWrappers;
    }  
  • Nice example. But I think if you try to create an Action on the list view it will require you to have a constructor function that takes a StandardSetController as a parameter. I found that I couldn't do both single record action and list action at the same time – abd3721 Jan 4 '17 at 0:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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