You need to sign in to do that
Don't have an account?
Override standard Save method called from standard Save button on standard Object (eg Opportunity)
Hi,
I have built this VF page :
<apex:page standardController = "Opportunity" extensions = "RefreshPage" standardStylesheets = "true" showHeader = "true" > <apex:detail subject="{!id}" showChatter="true" relatedList="false" inlineEdit="true" /> <c:ConditionsTarifairesV3 /> <apex:relatedList list="OpportunityContactRoles"/> <apex:relatedList list="OpportunityPartnersFrom"/> <apex:relatedList list="OpenActivities"/> <apex:relatedList list="ActivityHistories"/> <apex:relatedList list="NotesAndAttachments"/> <apex:relatedList list="ProcessSteps"/> </apex:page>
Basically, I replace the display and management of opportunity lines, but display the opportunity detail in the standard way, allowing for inlineEdit.
When a user updates a certain field (by inlineediting in the opportunity, I want to redisplay the whole page (opp + lines).
To do this, I just need to redefine the Save method of Opportunity in the RefreshPage controller extension :
public class RefreshPage { public ApexPages.StandardController stdCtrl { get; set; } public RefreshPage(ApexPages.standardController std) { stdCtrl = std; } // Overloading standard Opportunity save behaviour public PageReference save() { stdCtrl.save(); System.Debug('#### RefreshPage : in save()'); return Apexpages.currentPage(); } }
This does not work : the ines are not redisplayed, i.e the whole page is not redisplayed.
Any ideas why ? Any other solutions ?
Thanks for you contributions,
Rup
Josh,
Thanks for your answer, which was 90% perfect, for what I am trying to do.
In the end, this is my solution :
location.reload forces the whole page to reload, as opposed to just refresh : the difference is that when the page reloads, my custom component is reinitialized, which reloads the opportunity lines (which change based on values in the opp).
Thanks for you help,
Rup
All Answers
I think the inlineEditing is saving the record with its own agenda, so to speak. The save button there calls some JavaScript, i.e.:
To perform the save. Whereas I think the save function itself is bound to the save() method - if that makes sense. Inline Editing is a bit tricky like that (it also gets around the apex:form requirement, if that shows how "unbound" it is).
However, since this is JavaScript you could rehook the original function like so:
Which will retain the original function, insert your own code and then execture the old function. I've got that snippet under my form tag (it could probably go at the bottom of your page) and it seems to behave.
Note that what I'm describing here is probably not technically "supported"...
Josh,
Thanks for your answer, which was 90% perfect, for what I am trying to do.
In the end, this is my solution :
location.reload forces the whole page to reload, as opposed to just refresh : the difference is that when the page reloads, my custom component is reinitialized, which reloads the opportunity lines (which change based on values in the opp).
Thanks for you help,
Rup