What I'm trying to do is on column click, I want it to execute a backend function to store the value that was selected.

<apex:pageBlockTable rows="5" rendered="{!(foundResults==true)}" value="{!searchResultsAcc}" var="temp">
  <apex:column value="{!temp.Name}"  onclick="setSource('{!temp.Name}','{!temp.ID}');"/>
  <apex:column value="{!temp.ID}"/>
  <apex:column value="{!temp.LastModifiedByID}"/>

From here, on the click it will call this function in my script tag within my VF page :

  function setSource(var3,var4){

The alerts are just for testing to see if its actually coming here on the click and it is successfully going there.

<apex:actionFunction name="callsetSource" action="{!setSource}">

From the function within the script tag, I call the action function. I was assuming that it would be checking for the setSource() that has 2 parameters but it keeps going to the setSource() that has no parameters. I really doubt my values are actually getting passed to the action function tag, hence, its going to the setSource() without parameters


1 Answer 1


You could adjust your action function like so:

<apex:actionFunction name="callsetSource" action="{!setSource}" rerender='none'>
    <apex:param name='var3' value=''/>
    <apex:param name='var4' value=''/>

Then in your setSource method, you could retrieve the values like this:

String var3 = ApexPages.currentPage().getParameters().get('var3');
String var4 = ApexPages.currentPage().getParameters().get('var4');

The parameters don't get passed in as arguments to the controller method.

Edit: you must use the reRender attribute of the actionFunction for the parameters to be passed to the controller method. As noted by this known issue.


You must log in to answer this question.

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