You need to sign in to do that
Don't have an account?
Save and refresh only the VF page on the Page layout section
HI there,
I Have a very simple VF page that uses the standard controller "projects__C". The only reason the page exists is to display certain fields of the custom object in a certain way. It has a save button, so it saves the values of the specific fields on the record. Regardless, the page works fine and I have a little Javascript that simply redirects the page after saving it. Well, That works fine in Google Chrome, as when you hit the SAVE, the record is saved and the page refreshes just fine. NOw in Firefox, the whole page for the preoject__C record reloads within the section where the VF page was supposed to be.
All I need it to have the save button just to SAVE the record and NOT load the main page into the VF page Section.
here is the code:
<apex:page standardController="Projects__c" showHeader="false" > <apex:form id="f1" > <table width="90%" columns="3" align="left"> <td align="right"><b>PM Owner: </b></td><td align="left"><apex:inputField value="{!Projects__c.PM_Owner__c}" /></td> <td align="right"><b>PM Start date:</b></td><td align="left"><apex:inputField value="{!Projects__c.PM_Start_Date__c}" /></td> <td align="right"><b>PM Hours:</b></td><td align="left" width="70"><apex:inputField value="{!Projects__c.PM_Hours__c}" /></td><tr/> <td align="left"><apex:commandButton value="Save" action="{!save}" onclick="savemenow();" oncomplete=""/></td> </table> <script> function savemenow() { var url='/{!Projects__c.id}'; window.location.href= url; navigateToUrl('/{!Projects__c.id}'); return true; } </script> </apex:form> </apex:page>
Thanks!
B
You'll need an extension I'm afraid - as to why it works in one browser and not another, that's browsers!
All Answers
I reckon this is some because the pagereference returned from the standard controller save is overriding your javascript redirect.
The way I've handled this in the past is to have a small extension controller that saves the record and then indicates to the embedded VF page that the entire window should be refreshed. I wrote a blog post on this at:
http://bobbuzzard.blogspot.co.uk/2011/05/refreshing-record-detail-from-embedded.html
However, in your case its probably good enough to delegate the save up to the standard controller and then return null to refresh the VF page.
Bob! As usual, great stuff on the blog post you sent. I agree and on my case, I'm trying ot keep it on the standard controller without having to build an extension.
for that, how do I "return null" without building an extension. Still curious why it works in Chrome and not in Firefox... anyways.. Always good help Bob! Thanks again.
B
You'll need an extension I'm afraid - as to why it works in one browser and not another, that's browsers!
yeap... just browsers. I'll have to throw the towell and go for the extension. :)
Thanks again BOB!