My <apex:actionFunction> keeps reloading the VF page even though it does have a reRender attribute and the controller method returns null. Below are part of my code:


<apex:pageMessages id="page_message" />
<apex:actionFunction name="testConnection"  action="{!testConnection}" reRender="page_message" onComplete="displayConnectionInfo();" />

onComplete function:

function displayConnectionInfo() {
    return false;

Controller method:

public pageReference testConnection() 
    ApexPages.Message connection_info = Util.testConnection();

    return null;

My another page has a similar button and actionfunction and does work very well without reloading the page. There must be something I missed here but I am not sure what is it.

  • two question from where you are calling this actionfunction and overridePageMessages(); what this function do? Dec 12 '16 at 5:17
  • @TusharSharma testConnection basically test connection between Salesforce and our system. overridePageMessages() simply converts <apex:pageMessages> into lds style. I assure you there is no page loading code in Javascript. I have double checked.
    – Lance Shi
    Dec 12 '16 at 5:20
  • Can you just comment overridePageMessages(); and try.
    – Reshma
    Dec 12 '16 at 5:22
  • @Reshma Just tried. Still refresh. It doesn't even go into the onComplete method when I debug
    – Lance Shi
    Dec 12 '16 at 5:24
  • 1
    @LanceShi - How are you executing the actionFunction? via script, button, link?
    – Eric
    Dec 12 '16 at 23:50

if you are using commandButton and using Onclick function so please make sure to use "return false" inside Onclick function.

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.