2

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}"/>
</apex:pageBlockTable>

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

<script>
  function setSource(var3,var4){
    alert(var3)
    callsetSource(var3,var4);
    alert(var4);
  }         
</script>

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

0

1 Answer 1

2

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=''/>
</apex:actionFunction>

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.

0

You must log in to answer this question.

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