[SalesForce] Action Function Param Not Passing to Controller

EDIT: I needed to put a ReRender, but why?


Trying to pass an action function param to the VFP's custom controller. The value is not passing as passedVariableString returns null on the debug. Where am I going wrong?

Initiated in between script tags on VFP:

var variable = 'some text here';
launchActionFunction(variable);

On same VFP:

<apex:actionFunction action="{!launchActionFunction}" name="launchActionFunction">
       <apex:param name="passedVariable" value=""/>
</apex:actionFunction>

On Controller

public void launchActionFunction()
    {
    string passedVariableString = 
    system.CurrentPageReference().getParameters().get('passedVariable');
    system.debug(passedVariableString);
    }

Best Answer

Salesforce has built the framework for apex:actionFunction like that way that it expects rerender attribute to pass value to the controller and the ID of one or more components that are redrawn when the result of the action method returns to the client.

If you don't want to rerender anything, then use rerender="none".

<apex:actionFunction action="{!launchActionFunction}" name="launchActionFunction" rerender="none">
       <apex:param name="passedVariable" value=""/>
</apex:actionFunction>

For more information, refer apex:actionFunction

Related Topic