[SalesForce] Visualforce page reloads itself after actionFunction call

I would like to use the component apex:actionFunction to set a variable from a custom controller but after the call, the Visualforce page reloads itself. :/

I use return false; on the outputLink component and the rerender attribute but it doesn't work.

This is my code :

Visualforce page :

<apex:form>
        <apex:actionFunction name="setTheSource" action="{!setTheSource}">
            <apex:param name="selectedSource" value="{!$Label.Labs_Sf_Formulaire_QR_Label}" assignTo="{!selectedSource}" />
        </apex:actionFunction>
</apex:form>

<apex:outputLink value="#" id="contactusForm" onclick="setTheSource(); return false; showFeedbackDialog(); return false;" rendered="{!pkbCon.selectedLanguage != 'ru'}" >{!$Label.Labs_Sf_Contact_Us}</apex:outputLink>

Custom controller :

public String selectedSource {get;set;}

public PageReference setTheSource()
    {
        System.debug('SOURCE HERE!!! ' + ApexPages.currentPage().getParameters().get('selectedSource'));
        this.selectedSource = ApexPages.currentPage().getParameters().get('selectedSource');

        return NULL;
}

Have you any idea for why it doesn't work please?

Thanks for the help. 🙂

Best Answer

Instead of using false in the rerender attribute, you should just leave is blank. Example rerender="". That has worked for me.

Related Topic