I am not able to pass String List to Apex Controller using the apex:actionFunction.

Here is the complete code:

<apex:actionFunction action="{!methodOne}"
    name="methodOneJS" reRender="panelOne">
    <apex:param name="recordId" assignTo="{!selRecId}" value="" />



public List<String> recordId{get;set;}

I believe the type attribute on tag won't support list as a value. You have to specify using array-notation.

<apex:attribute name="recId"
    type="String[]" required="true" assignTo="{!recordId}" />
  • Tried this already..but it throws same kind of error: Type mismatch for <apex:attribute assignTo>. Value binding to a property of type String is required, property specified (recordId) is of type List<String>. – javanoob Mar 16 '15 at 18:22
  • You are correct. It is working for attribute, I am having issue in sending from actionFunction. – javanoob Mar 16 '15 at 21:31
apex:attribute name="recId" description="List of Id" type="String[]" 
           required="true" assignTo="{!recordId}"

--This should work because I just replicated the same in my dev org.

  • Datatype in the controller is List<String> ? – javanoob Mar 16 '15 at 21:03
  • Yes sir exactly like yours. Dont know why cant you save. Can you try again. Or plz post full vf code. – the_phantom Mar 16 '15 at 21:14
  • thanks for the reply but just one question did you overwrite the get or set properties? – javanoob Mar 16 '15 at 21:18
  • I didnt do anything except writing the way you did. List<string>recordid{get;set;} – the_phantom Mar 16 '15 at 21:20
  • I think i confused everybody. I am having trouble with passing values from actionFunction not the attribute. However I edited my question, Can you please take a look? – javanoob Mar 16 '15 at 21:30

if you are unable to use assignTo than don't use it. Simply write: apex:param name="recordId" name = "myparam" value=""

and in your controller method: String myparam = Apexpages.currentpage().getparameters().get('myparam'); system.debug('myparma is: '+myparam); --> will give the value you passed from JS.

Question - Why are you anyways assigning the record Id to a list?

  • I used the solution from this answer, salesforce.stackexchange.com/questions/9300/… as I am also passing Ids. – javanoob Mar 17 '15 at 15:49
  • I don't think you can pass a list. You will have to send one by one as a string and then get that from the pagereference map, like I wrote earlier. Or you can also adopt the way in the link you have provided just now. – the_phantom Mar 17 '15 at 16:00
  • I am using like mentioned in the link. Thanks all for your help – javanoob Mar 17 '15 at 17:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.