Find your content:

Search form

You are here

pass actionFunction name of variable to set in controller?

 
Share

Is it possible to pass the actionFunction the name of variable you want it to set in the controller? Right now I need a separate actionFunction for each field I'm setting onChange. Is it possible to make it more generic where the actionFunction receives the variable name and the variable value to set in the controller?

I don't see how this would be possible, but could it be accomplished through javascript remoting?


Attribution to: Phil B

Possible Suggestion/Solution #1

Yes, you can use apex:param(s) inside the actionFunction to send values into the controller. The value attribute can be a controller variable as shown in the docs example or set with a javascript call.

Here is something I put in use recently-

<apex:actionFunction name="setTableData" action="{!setTableData}"
        immediate="true" rerender="pgMsgs, matrixTopPanel"
        oncomplete="oTable.fnAddData({!tableData});">
    <apex:param name="sd" assignTo="{!selectedDivision}" value="" />
</apex:actionFunction>

which is called from javascript with setTableData(j$(this).val());


Attribution to: zjeh
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/4449

My Block Status

My Block Content