function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RostRost 

How to include page with custom controller?

I have a 3 VisualForce pages with almost identical content, but working with different controllers. I tried to extract common content and use <apex:include> tag but got following problems:

 

1. Page does not compile unless it is a "complete" page with <apex:page> tags, although the intent is to include that page into another ("main") page. I had to add <apex:page> tags.

 

2. Then page would not compile because it references custom controller data structures. I had to add controller description at the top. Now both "main" and "include" pages have controllers defined, with "include" page having a preference! As a result, I no longer can use different controllers at my 3 separate pages.

 

Is there a solution to this problem?

Best Answer chosen by Admin (Salesforce Developers) 
imuinoimuino

Im not sure i completley understand your problem, but do you know about components?

i think thats what you are looking for

https://na7.salesforce.com/apexpages/apexcomponents.apexp

 

Search for apex:component tag in this documentation

All Answers

imuinoimuino

Im not sure i completley understand your problem, but do you know about components?

i think thats what you are looking for

https://na7.salesforce.com/apexpages/apexcomponents.apexp

 

Search for apex:component tag in this documentation

This was selected as the best answer
RostRost
Thanks! In a nutshell, I needed a possibility to pass parameter to the controller before page is displayed and <apex: attribute> in components was the solution.