You need to sign in to do that
Don't have an account?
VisualForce page Error Message is not displaying inside the Standard Object Layout
Have a standard object layout that includes a visualforce page. With in the visualforce page there is a apex:commandLink, the action for the commandLink is point to a function of a pageReference. If validation false the error message gets load to apex:pageMessages. The issue we are having is the pageReference is causing the visualforce page redirect out of the standard object layout. We do not want this behaviour! We want the error message to display within the standard object layout or even better in the visualforce page with in the standard object layout. FYI --> PageReference returns Null.
Also we try pointing back to the standard object layout but we lost the error messages when return to the standard object.
Any ideas why this is happening?
Code from the extensions of the VF page:
Public PageReference Name() {
PageReference pageRef = null;
.......
if (ApexPages.hasMessages(ApexPages.Severity.Error)) {
Database.rollback(sp);
}
return pageRef;
}
Page Code
<apex:page standardController="standardController" extensions="extensions" >
<apex:pageBlock >
<apex:pageMessages />
<apex:actionRegion >
<apex:form id="theform" >
............
<apex:commandLink action="action" value="Value" target="_top" />
I suspect this is due to the target attribute on the command link. This is telling the browser to load the contents of the link into the topmost frame - i.e. the resulting page fills the entire window.
Remove that attribute and you should see just the embedded VisualForce page refresh.
All Answers
I suspect this is due to the target attribute on the command link. This is telling the browser to load the contents of the link into the topmost frame - i.e. the resulting page fills the entire window.
Remove that attribute and you should see just the embedded VisualForce page refresh.
Thank you bob_buzzard. Yes removing the the target does stop the VF from removing itself from the standard object layout. The only issue with that is we want to refresh the standard object layout if the VF pasts validation.
Do you know a better way to refresh standard object layout?
Hmm. I don't think you'll be able to do this from the controller, as you would need the browser to pick a different target based on the results of the form submission.
The only way I can think of at the moment is to set a property in the controller that indicates validation succeeded and then have some javascript programmatically follow a link with a target of _top.
try to give some error messag like
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'YOUR ERROR MESSAGE HERE'));