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
uxtx_timuxtx_tim 

apex include vs iframe

I'm evaluating two ways of embedding vf pages inside each other, essentially two ways of doing the same thing:

 

The first with an iframe
<iframe src="{!pageUrlString}" width="800" height="700" ></iframe>


The second with a page include         
<apex:include id="pageArea" pageName="{!pageUrlString}" rendered="true"/>

The iframe renders the second page just fine.

The apex include gives an internal server error.

 

 

An internal server error has occurred
An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact Salesforce Support. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience. 

Thank you again for your patience and assistance. And thanks for using salesforce.com! 

Error ID: 949465384-11147 (680958693)

 

My question is am I using the apex include component wrongly or do I need to open a ticket?

 

bob_buzzardbob_buzzard

That looks like correct use of apex:include to me.  Can you give an example of what pageUrlString would look like?  If you hardcode the string does it work?

 

I've been told by SF support that an internal server error is an error condition that isn't trapped or handled by the platform, so I'd imagine that you'll need to open a ticket to get a resolution.

bob_buzzardbob_buzzard

One more thing - according to the VF docs, the attribute type needs to be ApexPages.PageReference, so your getter may need to return a PageReference rather than a string to work correctly.

uxtx_timuxtx_tim

an example url string looks like this

 

 

'/apex/GoogleTimeChart?signal=000091356';

 

im currently trying to rewrite my controller so the string get's represented as a page reference object.

 

Damien_Damien_

return new PageReference('/apex/GoogleTimeChart?signal=000091356');

bob_buzzardbob_buzzard

The parameters may be causing the problem here - its not 100% clear from the docs, but it looks like include wants a page rather than a page with params.

uxtx_timuxtx_tim

I thought that might be the case. 

A colleague and I had discussed parsing the string and then using getParameters().put in the controller to see if that works.  Do you think that might be worth exploring?  I don't know if I'm up for going down another fruitless path - need to move on...

 

Thanks for your help by the way - it has been very beneficial

bob_buzzardbob_buzzard

Here's another thought.

 

If a page that is added via apex:include uses the same controller class as the "parent" page, they will share the same instance of the controller.  This would allow you to share information between the pages if you can craft a controller that is suitable for both pages.

Prajapati.LakhanPrajapati.Lakhan

Hi Bob,

 

I am little bit confused while choosing between <apex:include> and <apex:iframe>, following are my observations:

 

"If a page that is added via apex:include uses the same controller class as the "parent" page, they will share the same instance of the controller."

 

Having same instance of the controller, the cost associated with this approach is that view state gets increased twice.

 

So my question is that if I need to reuse only one method of that controller then should I use <apex:include> with the same controller or should I create separate controller ?

 

Thanks,

Lakhan

Damien_Damien_

If you only need to share 1 method, it really depends on what that method does.

 

1) Do you pass in parameters, and then it does work purely what you passed in to return some sort of result?

You can simply have a static method to do this work, because it can be called from your second controller still.

 

2) Your classes are completely different, but have a single method exactly in common?

You can have a parent abstract class, that has that single method in it, then have both controllers extend it.  Shares the method, but you only have to write it once.  Note-if you have the same variables in both, you can put these in the abstract class also.

 

3) Is it a small view state to be duplicating?

Then its probably not a big deal to duplicate the view state.  Another question on this though, are you 100% sure it would duplicate the view state?  Because when I think of something sharing a same instance, I think of only 1 of them existing.  Not being duplicated.  This could potentially not be the case since I don't know how Salesforce implemented it, but it's worth taking a look.

Prajapati.LakhanPrajapati.Lakhan

Hi Damien,

 

For question #3, It just shows view state twice for the same controller and sum is rolled up to the controllers section but never count the duplicate view in actual view state size. I just tried it by creating a VF page and a controller with view state of size 102 KB and included a page (by apex:include) with same controller  in this page and observed the view state, it showed view state size as 204KB as cummulative view state size for controllers(no exception for view state size limit 135KB !!!! ) but overall cummulative view state size was less than 204KB but greater than 102KB.

 

Thanks again for the solution.

 

 

Thanks,

Lakhan