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
amoldavskyamoldavsky 

common.page.PageInterruptException

Hey,

 

I keep getting this exception in the VF iframe whenever I try to redirect anywhere...

Content cannot be displayed: Exception common.page.PageInterruptException

 

The code that generates this is:

public PageReference appInit() {
	if(false) return null; // for now
	PageReference pageRef = Page.Login;
	pageRef.setRedirect(true);
	return pageRef;
}

 

This method is called from here (on the VF page)

<apex:page language="en" StandardController="Account" showHeader="true" standardStylesheets="true" sidebar="false" extensions="StartupExtension,ZoomAccountExtension" action="{!appInit}">

 

Is I return null I stay on the same page and I do not get this exception but if I try to redirect no matter where I get this exception.

 

Any ideas? please help!!

 

 

-Assaf

Best Answer chosen by Admin (Salesforce Developers) 
amoldavskyamoldavsky

It's a SF bug when you try to do redirect from <apex:page actions="someMethod"> which should be fixed soon from what I understood. There are a bunch of other people having this problem:

http://success.salesforce.com/questionDetail?qId=a1X30000000dHxVEAU

 

So basically the solution for now is basically to use Javascript

 

Here is a response from SF:

6/12/2012 3:33 PM | Jitender Bhatia
Hi Assaf,

As you mentioned the Case#07675883 in the case description, Tier 3 has provided the workaround on this case and it has been shared already.

I am providing you the details what has been communicated earlier as a workaround on this issue.

There are two possible work-arounds suggested by Tier3 that you can try and implement. This code has only been tested in our test environment, not yours, is not considered production ready as-is, and should be given the full UAT treatment. It may also need to be adjusted to match your specific requirements.

1. Move the action into a commandButton i.e. instead of keeping action="{!redirectCommand}" in the <apex:page> tag, move it into a form and button. Example:

This code:

<apex:page standardController="Account" extensions="someClass" action="{!redirectCommand}">

becomes:

<apex:page standardController="Account" extensions="someClass >

<apex:form >
<apex:commandButton id="clickMe" value="Click Me To Reload Page Element" action="{!redirectCommand}"/>
</apex:form>

This will require users to click the button to see the VF page, though.


2. Use Javascript remoting to automatically call the redirect method. You want to add the RemoteAction to your extension class, which does exactly the same thing as your original {!redirectCommand}. Example:

- Add this method to your extension class. This method should do the same thing that your original redirect method should, i.e. construct the correct PageRef URL including id's, and return it:

@RemoteAction
global static PageReference redirectCommandClone(String s){
PageReference customPage = Page.NameofVFPageToBeRedirectedTo;
return customPage;
}

- Add this to your Visualforce page:

<script type="text/javascript">
function remoteRedirect() {

Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.ClassName.redirectCommandClone}',
"",
function(result, event){
if (event.status) {
window.location.href=result;
} else if (event.type === 'exception') {
document.getElementById("responseErrors").innerHTML = event.message;
} else {
document.getElementById("responseErrors").innerHTML = event.message;
}
},
{escape: true}
);
}

if (window.attachEvent) {
window.attachEvent('onload',remoteRedirect);
} else {
window.addEventListener('load',remoteRedirect);
}
</script>

This issue is a known issue which is already under our observation and our Product Development team is working on it.

Unfortunately, I will not be able to provide you a date when this issue will cease to exist. You will be notified once the issue is resolved as the status of earlier case is "Bug fix Submitted".

We do apologize for the inconvenience caused due to this.

Thanks & Regards
Jitender Bhatia
Developer Support Engineer
salesforce.com

 

All Answers

PentiPenti

Have you been able to fix this error yet?  We are getting the same error with a VF page.  I just submitted a message on the Visualforce board about it:

 

http://boards.developerforce.com/t5/Visualforce-Development/Visualforce-page-suddenly-displaying-an-error/td-p/453167

amoldavskyamoldavsky

It's a SF bug when you try to do redirect from <apex:page actions="someMethod"> which should be fixed soon from what I understood. There are a bunch of other people having this problem:

http://success.salesforce.com/questionDetail?qId=a1X30000000dHxVEAU

 

So basically the solution for now is basically to use Javascript

 

Here is a response from SF:

6/12/2012 3:33 PM | Jitender Bhatia
Hi Assaf,

As you mentioned the Case#07675883 in the case description, Tier 3 has provided the workaround on this case and it has been shared already.

I am providing you the details what has been communicated earlier as a workaround on this issue.

There are two possible work-arounds suggested by Tier3 that you can try and implement. This code has only been tested in our test environment, not yours, is not considered production ready as-is, and should be given the full UAT treatment. It may also need to be adjusted to match your specific requirements.

1. Move the action into a commandButton i.e. instead of keeping action="{!redirectCommand}" in the <apex:page> tag, move it into a form and button. Example:

This code:

<apex:page standardController="Account" extensions="someClass" action="{!redirectCommand}">

becomes:

<apex:page standardController="Account" extensions="someClass >

<apex:form >
<apex:commandButton id="clickMe" value="Click Me To Reload Page Element" action="{!redirectCommand}"/>
</apex:form>

This will require users to click the button to see the VF page, though.


2. Use Javascript remoting to automatically call the redirect method. You want to add the RemoteAction to your extension class, which does exactly the same thing as your original {!redirectCommand}. Example:

- Add this method to your extension class. This method should do the same thing that your original redirect method should, i.e. construct the correct PageRef URL including id's, and return it:

@RemoteAction
global static PageReference redirectCommandClone(String s){
PageReference customPage = Page.NameofVFPageToBeRedirectedTo;
return customPage;
}

- Add this to your Visualforce page:

<script type="text/javascript">
function remoteRedirect() {

Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.ClassName.redirectCommandClone}',
"",
function(result, event){
if (event.status) {
window.location.href=result;
} else if (event.type === 'exception') {
document.getElementById("responseErrors").innerHTML = event.message;
} else {
document.getElementById("responseErrors").innerHTML = event.message;
}
},
{escape: true}
);
}

if (window.attachEvent) {
window.attachEvent('onload',remoteRedirect);
} else {
window.addEventListener('load',remoteRedirect);
}
</script>

This issue is a known issue which is already under our observation and our Product Development team is working on it.

Unfortunately, I will not be able to provide you a date when this issue will cease to exist. You will be notified once the issue is resolved as the status of earlier case is "Bug fix Submitted".

We do apologize for the inconvenience caused due to this.

Thanks & Regards
Jitender Bhatia
Developer Support Engineer
salesforce.com

 

This was selected as the best answer
PentiPenti

That's very helpful.  Thank you for sharing this information.