How to map a Visualforce page to an object's layout which is using custom controller. As I have seen if you use standard controller then only you can map visualforce to the page layout. But what to do when we have custom controller in Visual Page and wants to map it object's layout.

2 Answers 2


here it is a small example.


<apex:page standardController="Custom__c" extensions="CustomController" showHeader="true" sidebar="true">


public with sharing class CustomController {

    public CustomController(ApexPages.StandardController controller) {
        Id standardId = controller.getId();


private class CustomControllerTest {

    @isTest static void test_controller() {
        ApexPages.StandardController controller = new ApexPages.StandardController(new Custom__c());
        CustomController ctrl = new CustomController(controller);
  • Is this the only way by using extension..! no other possible way is available other than this.
    – Lovel_leo
    Commented Apr 22, 2016 at 12:28

You have to use standard controller and have your custom code in extension class. FYI There is standard controller for custom object.

  • Please mark as best answer if it solve your issue.
    – Rachit
    Commented Apr 22, 2016 at 6:04

You must log in to answer this question.

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