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
Jay EcklesJay Eckles 

can't get VF pages embedded in standard page layouts to work

Enterprise Edition, Winter 13.  I have a simple VF page:

 

<apex:page standardController="Account">
Hello, world.
</apex:page>

 I have tried to embed this VF page into my one and only Account page layout.  When I go to the page layout (that is go to view a particular Account record in SFDC), there is just a big blank white space where the VF page should be rendering.

 

If I try to access the VF page directly (https://[instance].salesforce.com/apex/test_page), it renders no problem, giving me my "Hello, world." greeting.  

 

I've poked around in security settings, I've tried embedding it in other object page layouts (i.e., Contacts where it doesn't work and Cases where it does work), I've tried wrapping my "Hello, world." in an apex:outputPanel.  I've tried creating a generic extension class that doesn't do anything but lets me specify the extensions attribute to the apex:page component.  I've checked the security on the page and granted access to all profiles.  I've confirmed this behavior is the same in sandbox and production.  I'm not hitting any limits.  I've checked record types.

 

At this point I'm at a loss.  Help!

Best Answer chosen by Admin (Salesforce Developers) 
Jay EcklesJay Eckles

Problem solved.

 

View under Accounts "Button and Links" was overridden to a VF page we call orgDetail.  That VF page does some stuff, calls 

 

<apex:detail subject="{!Account.Id}" inlineedit="true"/>

 to render the "normal" page layout, and then does some more stuff.  

 

The problem is that the consultant who built the orgDetail VF page put his apex:form component at the very top of the page, meaning the apex:detail component was contained by the apex:form component.  There were posts on this board and others complaining that VF pages embedded in layouts were not displaying when an apex:detail component had inlineedit="true" and was contained within an apex:form component.  Salesforce fixed the problem in Spring 11 by not requiring apex:detail to be contained by a form.

 

I moved the apex:form component opening tag below this apex:detail component and the problem is solved.

 

The technical reason this all fails is because of how Salesforce embeds VF pages in a page layout.  The generated HTML for the embedded VF page is an iframe element with no src, just an id and name.  Following that is a form element with an action to servlet.Integration, targeting the id of the iframe.  The form includes hidden inputs for what appear to be a couple of session keys.  Following that form is inline javascript to submit the form.  The servlet.Integraiton presumably just redirects to the VF page with the ID of the original page's record, and the redirection is displayed in the iframe.

 

But, because my original page is itself embedded in an outer VF page, and that outer VF page puts form tags around the detail element, the resulting HTML is a form within a form.  That makes the HTML invalid and when the javascript tries to submit the inner form, it doesn't exist because of the invalid HTML.

 

All Answers

Mohith Kumar ShrivastavaMohith Kumar Shrivastava

Please Post screen shot of the Pagelayout along with above section from where we drag the Vf page to the blank section so that we may visualize and help you.

vishal@forcevishal@force

I wasn't able to replicate this. Tried a few cases, but worked in all.

Jay EcklesJay Eckles

Jay EcklesJay Eckles

FYI, I've also submitted this as a case with SF support.

Jay EcklesJay Eckles

Problem solved.

 

View under Accounts "Button and Links" was overridden to a VF page we call orgDetail.  That VF page does some stuff, calls 

 

<apex:detail subject="{!Account.Id}" inlineedit="true"/>

 to render the "normal" page layout, and then does some more stuff.  

 

The problem is that the consultant who built the orgDetail VF page put his apex:form component at the very top of the page, meaning the apex:detail component was contained by the apex:form component.  There were posts on this board and others complaining that VF pages embedded in layouts were not displaying when an apex:detail component had inlineedit="true" and was contained within an apex:form component.  Salesforce fixed the problem in Spring 11 by not requiring apex:detail to be contained by a form.

 

I moved the apex:form component opening tag below this apex:detail component and the problem is solved.

 

The technical reason this all fails is because of how Salesforce embeds VF pages in a page layout.  The generated HTML for the embedded VF page is an iframe element with no src, just an id and name.  Following that is a form element with an action to servlet.Integration, targeting the id of the iframe.  The form includes hidden inputs for what appear to be a couple of session keys.  Following that form is inline javascript to submit the form.  The servlet.Integraiton presumably just redirects to the VF page with the ID of the original page's record, and the redirection is displayed in the iframe.

 

But, because my original page is itself embedded in an outer VF page, and that outer VF page puts form tags around the detail element, the resulting HTML is a form within a form.  That makes the HTML invalid and when the javascript tries to submit the inner form, it doesn't exist because of the invalid HTML.

 

This was selected as the best answer