1

I have a visualforce page with 2 constructors

public customExtension(ApexPages.StandardSetController stdSetController) {

public customExtension(ApexPages.StandardController stdController){

The page is defined a

apex:page showHeader="true" sidebar="true" standardController="Job_Application__c"
tabStyle="Job_Application__c" extensions="customExtension" recordSetVar="varRecords">

I'm trying to make the page accessible from both a detail button to put on the objects standard layout and a list view button so it's accessible from a related list of objects on the parent record. If I remove the recordSetVar from the page definition I can define a detail button but not a list view and of course vise versa. Is there a way to make this work without having to define two different pages?

3

You need separate Visualforce Pages, because the only difference is recordSetVar. You can put the entire body into a Visualforce Component in the spirit of DRY. I omitted irrelevant attributes for brevity.

Detail

<apex:page standardController="Job_Application__c" extensions="MyExtension"
    recordSetVar="applications">

    <c:jobApplicationWidget someParam="{!someProperty}" />

</apex:page>

List

<apex:page standardController="Job_Application__c" extensions="MyExtension">

    <c:jobApplicationWidget someParam="{!someProperty}" />

</apex:page>
| improve this answer | |

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.