My workflow looks something like this:
- I have a button in the related list to create a NEW custom object record with a custom visualforce page (VFNew.page)
- Open the saved record with an Edit button which is overridden with a custom visualforce page (VFEdit.page)
Here where it gets a bit complicated: both the visualforce pages have the same visualforce component embedded into them.
VFNew.page (used in a button from the related list) ->
<apex:page id="page" docType="html-5.0" standardController="Custom__c" recordSetVar="cItems" ..>
<c:customComponent />
</apex:page>
VFEdit.page (used in an Edit button override)->
<apex:page id="page" docType="html-5.0" standardController="Custom__c" ..>
<c:customComponent />
</apex:page>
CustomComponent.component ->
<apex:component extensions="CustomController" allowDML="true">
</apex:component>
Controller class ->
public with sharing class CustomController{
public CustomController(){
System.debug('1');
init();
}
public CustomController(ApexPages.StandardSetController controller){
System.debug('2');
init();
}
public CustomController(ApexPages.StandardController controller){
System.debug('3');
initEdit();
}
}
What I had hoped for is that when the VF is called from the related list button then the constructor 2 will be called because of the StandardSetController parameter and when the VF is called from the overridden Edit button then the constructor 3 will be called because if the StandardController parameter --- but in all the cases the constructor 1 is called - always.
Is there another way to find out in constructor 1 which Controller parameter is available so that I can get the Id if it comes from the Edit page?