1

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:

Markup:

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

onComplete function:

function displayConnectionInfo() {
    $(".slds-spinner_container").hide();
    overridePageMessages();
    return false;
}

Controller method:

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

    ApexPages.addMessage(connection_info);
    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.

15
  • two question from where you are calling this actionfunction and overridePageMessages(); what this function do? Commented Dec 12, 2016 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
    Commented Dec 12, 2016 at 5:20
  • Can you just comment overridePageMessages(); and try.
    – Reshma
    Commented Dec 12, 2016 at 5:22
  • @Reshma Just tried. Still refresh. It doesn't even go into the onComplete method when I debug
    – Lance Shi
    Commented Dec 12, 2016 at 5:24
  • 2
    @LanceShi - How are you executing the actionFunction? via script, button, link?
    – Eric
    Commented Dec 12, 2016 at 23:50

1 Answer 1

0

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .