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
CTU007CTU007 

can I reference a VF page inside another VF page?

Hi, I have created the "tabbed Opportunity" page, and now I created another page "opportunity detail".

 

So, can I reference this "opportunity detail" page in the "tabbed opportunity page"? By doing this, I can have various pages for different sections so the overall page is not so long.

 

 

<apex:page standardController="Opportunity" showHeader="true" > <style> .activeTab {background-color: #236FBD; color:white; background-image:none} .inactiveTab { background-color: lightgrey; color:black; background-image:none} body{margin: 0; padding: 0; font-size:9pt} </style> <apex:tabPanel width="100%" switchType="client" selectedTab="tabdetails" id="OppTabview" tabClass="activeTab" inactiveTabClass="inactiveTab" > <apex:sectionHeader title="{!$ObjectType.Opportunity.label}" subtitle="{!Opportunity.name}"/> <apex:tab label="Details" name="OppDetails" id="tabdetails" > <!-- how to reference the detail page here? --> $page.OpportunityDetail <!-- <apex:detail subject="{!Opportunity}" relatedList="false" title="true" --> </apex:tab> <apex:tab label="Open Activities" name="OpenActivities" id="tabOpenAct" > <apex:relatedList subject="{!opportunity}" list="OpenActivities" /> </apex:tab> </apex:tabPanel> </apex:page>

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
patrospatros
You might try the <apex:include> component. It allows you to bring in another page into the VF DOM context.

All Answers

patrospatros
You might try the <apex:include> component. It allows you to bring in another page into the VF DOM context.
This was selected as the best answer
CTU007CTU007

Thanks, I think this may help.

 

Just tried with the following error:

 

Error: 'apex:form' component cannot be nested within form tags

 

So have to think about workaround on the form nesting.

 

patrospatros

Crud.

 

Could you turn that view into a component and get re-use that way? I'm guessing you're goal here is to avoid creating what feels like a redundant page?

CTU007CTU007

Don't know how to create a component yet. but I think this is not a component.

 

My goal is to break the very long VF page into several smaller pages, so in the future it will be easier to update ---- hopefully.

 

Currently, I have overridden the "view" button on opportunity with the "tabbed opportunity view" page, then I created another "opportunitydetail" page to override the default detail page(I hide a lot of blank fields so the layout looks nicer).

 

Before I use the <include> tag, I have to copied markups from "opportunitydetail" page into the "tabbed opportunity view" page, which make the "tabbed" page very long.

 

 

I am not sure how many nesting we can use <include> to include other pages?

 

For example:

 

<apex:page id="parent page"> <apex:include pageName="childpage" /> </apex:page> then in childpage: <apex:page id="childpage" > <apex:include pageName="grandchildpage" /> </apex:page> then in grandchildpage: ... <apex:include pageName="anotherpage" /> .....

 

 

 

CTU007CTU007
This is like in programming, you call various module/procedure.
CTU007CTU007

I handled the form nesting issue.

 

Thanks a lot. 

waylonatcimwaylonatcim

How did you handle the nested forms issue?  I have a similar scenario to yours.

 

Thanks

CTU007CTU007
Hi, I simply removed the form tag in the referenced page.