3
<apex:actionFunction name="submitExpJS" action="{!submitExpenses}"  
    oncomplete="refreshMe();" reRender="messagePanel"/>  

<script>
function refreshMe() {    
    alert('refresh');  
}  
</script>

The function refreshMe() is not getting invoked.

13
  • Did you check if your action function is getting invoked as well or not? Mar 22 '16 at 1:34
  • It does! I tried this attribute oncomplete with a plain <apex:commandButton> and it works fine, it is just in the combination of <apex:actionFunction> that it remains silent. My intention is to refresh the page after calling an action function, i also tried PageReference.redirect from the action method, that also did not work. As an alternative, I wanted to try a javascript refresh function, which is also not working :(.
    – SF Learner
    Mar 22 '16 at 1:38
  • If your only purpose is to refresh the page after calling the actionFunction, you can simply remove the reRender attribute of the actionFunction tag and in your controller make the return type to be void. But as @Salesforcesmarty as mentioned, I also doubt about whether your actionfunction is getting invoked at all.
    – Lance Shi
    Mar 22 '16 at 1:44
  • actionFunction does NOT work without reRender, have a look at my recent post about it salesforce.stackexchange.com/questions/114559/…. Actionfunction is definetely getting called, it is updating the records, but the problem is, i need a manual Refresh to reflect the changes on the page. The page consists of a list with editable fields and 'Save' button.
    – SF Learner
    Mar 22 '16 at 2:22
  • 2
    try one thing use apex:pagemessage and rerender that. May be you are getting any exception. Mar 22 '16 at 5:35
2

I thought I would post this working sample code that I tried in my Developer edition org.

Controller:

public with sharing class SimplePageController {

    public Integer i{get;set;}

    public SimplePageController(){
        i =0;
    }

    public void justIncrement(){
        i = i+1;
        System.debug('From doNothing method on the controller');
    }

}

VF page:

<apex:page controller="SimplePageController" showHeader="false" Sidebar="false">
    <apex:form>
        <apex:outputPanel id="someDiv">
            <apex:outputText value="{!i}"></apex:outputText>
        </apex:outputPanel>
        <a href="#" onclick="actionFunctionJS();">Click Here</a> 
        <apex:actionFunction name="actionFunctionJS" 
                                action="{!justIncrement}" 
                                oncomplete="onCompleteJSFunction();" 
                                reRender="someDiv">
        </apex:actionFunction>
    </apex:form>

    <script type="text/javascript">
        function onCompleteJSFunction(){
            alert('From onCompleteJSFunction method');
        }
    </script>   
</apex:page>
4
  • I wish i could paste the code, but it is 100's of lines and it would be too cluttering here.. This is something i noticed, 1.oncomplete method is occasionally getting invoked and there is no pattern that i could relate it to. 2. when i update the list, it is taking a while to update the list, so even if i click on refresh, it is taking 2-3 refresh's to actually show the updated values, not sure what is going on..
    – SF Learner
    Mar 22 '16 at 6:03
  • @ShaliniMendu, Unfortunately the information you provided is not sufficient enough to help you. The code you posted in the question should work fine unless there are other conditions as you mentioned in this comment. If you can create a simple and short replica of your problem may be people can pitch in more. Thanks!
    – javanoob
    Mar 22 '16 at 13:06
  • @Shalini Mendu Just post your <apex:command button part here else where you invoke the "submitExpJS" javascript function name.
    – bharath
    Dec 9 '16 at 5:58
  • @bharat, this is a very old post. I must have got it fixed somehow :). Thank you anyway
    – SF Learner
    Dec 9 '16 at 6:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.