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
Ken_KoellnerKen_Koellner 

Embedding Visual FOrce page in standard layout. access to std contrllr? access to page layout?

Suppose I embed a Visual Force page in a standard layout and write a controller extention based on the controller on the same object as what the page layout is based.  For example, embed a Visual Force page in the Display page for Opportunity and write a class that extends the Opportunity controller. I'm was hoping to use standard control for the rest of the layout and extend the standard control for a few functions on my VF page but I still want to work in the context of the object on the page layout. I want to be able to pass data back and forth.

 

If I extend the Opportunity controller, do I get a new instance of the Opportunity controller that isn't the one control the regular page layout?

 

Do I get a different instance of the controller? (if that even makes sense, does a controller also drive standard layouts)

 

Is there anyway in my controller extention to refer back to the page layout?  What I really will want to do is rerender part, or maybe all, of the page.

 
Ron HessRon Hess

i think you can rerender the parent page, but not a partial page since it is in a different domain than your visualforce page.

 

You can refer to public portions of the opportunity controller in your controller using the parameter passed into your constructor.  That is your pointer to the page controller. 

 


Ken_Koellner wrote:

If I extend the Opportunity controller, do I get a new instance of the Opportunity controller that isn't the one control the regular page layout?


 

You get a new one, you don't have access to the code that controls the standard page, that is in a different domain.

 

 

I think the best you can do is make a change in the underlying record ( DML) and then cause the main page to reload by setting the window.parent.location.href.   i havent tried this lately, let us know if it works for you.

 

 

 

 

 

Philip_FPhilip_F

This thread is a little bit old, but I wanted to share the solution I came up with.  Ron's advice was on the right track, although I recommend using window.top.location.href since viewing a Visualforce page in "Development Mode" adds another frame into the DOM.

 

Here is some sample controller code.  In this code, I added a boolean flag to indicate whether a reload is neeeded.  If so, the outputPanel with the appropriate Javascript is rendered.  If not, then no reload happens. Enjoy!

 

public String pageURL {set;}
public Boolean reloadNeeded {get; set;}

public String getPageURL() {
	ApexPages.StandardController sc = new ApexPages.StandardController(<my_object_reference>);	
	PageReference pageRef = sc.view();
	return pageRef.getUrl();	
}

 

Here's the corresponding Visualforce code to conditionally do the redirect:

 

<!--  Do we need to reload the page? -->
<apex:outputPanel id="reloadPanel" rendered="{!reloadNeeded}" >
   	<script type="text/javascript">
		// redirect the top level window
		window.top.location.href = '{!pageURL}';
	</script>	
</apex:outputPanel>

 

Cheers,

-Philip

 

 

RizsoftRizsoft

Phillip,

 

Thank you for posting a solution to this. Been struggling for a few hours on this issue and your solutions works great!

 

Thanks, Dan