function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
asadimasadim 

actionFunction params not getting passed to controller

Hi,

 

I have this actionFunction:

 

<apex:actionFunction action="{!addStuff}" name="addStuffJS"> <apex:param name="firstParam" assignTo="{!xAdded}" value="" /> <apex:param name="secondParam" assignTo="{!yAdded}" value="" /> <apex:param name="thirdParam" assignTo="{!zAdded}" value="" /> </apex:actionFunction>

 and in the controller there is:

 

public String xAdded { get; set; } public String yAdded { get; set; } public String zAdded { get; set; } public void addStuff() { system.debug('added x: ' + xAdded); }

 

 

 The actionFunction is called from a JS script which itself is invoked after some button is pressed like so:

 

function btnActionJS() { for (var i=0; i < thisArray.size(); i++) { addStuffJS(thisArray[i]x, thisArray[i].y, thisArray[i].z); } }

 

The issue is that the values for xAdded, yAdded, and zAdded on the controller are all null when the button on the page is pressed (the debug statement on addStuff() prints null). Am I doing something wrong somewhere?!

 

Thanks.

 

 

Best Answer chosen by Admin (Salesforce Developers) 
asadimasadim
So turns out, in order for this to work I had to set the reRender attrib on the AF to some dummy element -don't ask me why please.

All Answers

asadim2asadim2
So after putting a debug statement in the setter of one of the public variables (xAdded) I found out that the thing does not even get called. Apparently my params are not passing their values up to the controller.
asadimasadim
So turns out, in order for this to work I had to set the reRender attrib on the AF to some dummy element -don't ask me why please.
This was selected as the best answer
benwrigleybenwrigley

I just had to do exactly the same! Elements were not being passed through unless I added a dummy reference to my rerender!

TomSnyderTomSnyder

 

Used this pattern in a few VF pages but since our upgrade to Winter 11 this no longer works.  The the param gets passed in the POST as before but never gets binded to property on the controller.

 

Anyone else having problems with passing parameters in the actionFunction since the release of Winter 11?

 

-Tom

GanjehGanjeh
This just worked for me.
AshishkAshishk
We have workaround for this problem, if we need to pass parameter and dont need rerender attribute, use 2 action functions, pass parameter with first function having rerender="none(something which is not existing as component)" and oncomplete of first function invoke another action function which will do remaining work of action and reload the page.
Dana Barnett 12Dana Barnett 12
Confirmed that the rerender is still required as of Summer 18 for the parameters to be passed.