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:actionFunction name="setTheSource" action="{!setTheSource}">
            <apex:param name="selectedSource" value="{!$Label.Labs_Sf_Formulaire_QR_Label}" assignTo="{!selectedSource}" />

<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. :)


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

  • 1
    It doesn't work for me, Salesforce redirect me. :/ The controller method is not called when I see the debug logs. Apr 23 '15 at 12:14

Try to make setTheSource method void. When you return null from an action method it's normal the VisualForce page to reload.

  • I'd be surprised if this matters; I use return type of PageReference in my actionmethods all the time and if I want to refresh the page, I return null.
    – cropredy
    Apr 23 '15 at 1:32
  • I forgot to tell you that I use a Visualforce component, a Force.com site and knowledge. I tested my code in another organization and it works. A Visualforce page calls a Visualforce component giving its controller. Visualforce Page => Apex controller => Visualforce component. Salesforce tried to redirect me to this URL : /knowledge/TOCArticleRendererPkb.apexp Apr 23 '15 at 12:09

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.