You need to sign in to do that
Don't have an account?
Bryan Jimenez 5
How can I add a controller extension to apex class
Hi Everyone,
I am having trouble adding a standardcontroller "Mclabs2__Sale" to my Custom controller below.
Can someone guide me in the right direction?
I am having trouble adding a standardcontroller "Mclabs2__Sale" to my Custom controller below.
Can someone guide me in the right direction?
global with sharing class ModalFlowAttachment{ global Flow.Interview.attachmentFlow2 myflow { get; set; } global string varAttachmentParentId = 'init'; global ModalFlowAttachment(){ myflow = new Flow.Interview.attachmentFlow2(new map<string, object>{'varAttachmentParentId'=> ''}); } global string getVarAttachmentParentId() { if(varAttachmentParentId == 'init'){ varAttachmentParentId = ''; return ''; } return myflow.varAttachmentParentId; } global Attachment attachment { get { if (attachment == null) attachment = new Attachment(); return attachment; } set; } global PageReference upload() { attachment.OwnerId = UserInfo.getUserId(); attachment.IsPrivate = true; attachment.parentId = getVarAttachmentParentId(); try { insert attachment; } catch (DMLException e) { ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading attachment')); return null; } finally { attachment = new Attachment(); } ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Attachment uploaded successfully')); varAttachmentParentId = null; return null; }
Use your custom controller as an extension and standardcontroller like
<apex:page standardController = "Account" extensions="myCustomController">
</apex:page>
OR
You should have a controller variable in your custom controller class and you should set that member variable to the inbound controller. like so:
public class MyCustomController{
private final ApexPages.StandardController controller;
public MyCustomController(ApexPages.StandardController controller){
this.controller = controller;
}
}
Anything you wish to initialize you'll need to add to the constructor that the vf page uses (it always uses the one with a controller, whether a standardcontroller or standardsetcontroller)
Thanks!
For more details plz refer these links
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_extension.htm
https://trailhead.salesforce.com/projects/salesforce_developer_workshop/steps/creating_controller_extension
Thank you