4

Here's what I have so far.

Controller

public Id[] SelectedIds {get;set;}
public void TestAction()
{
    system.debug(SelectedIds);
}

Page

<apex:outputpanel id="r"></apex:outputpanel>
<apex:actionfunction name="UpdateSelected" action="{!TestAction}" rerender="r"> 
    <apex:param name="ids" value="" assignTo="{!SelectedIds}" /> 
</apex:actionfunction> 

JavaScript

UpdateSelected(['a1we00000004EXAAA2','a1we00000004EXBAA2']);

Result

Invalid conversion from runtime type String to LIST
Error is in expression '{!SelectedIds}' in component in component

10

Actually you cant send a list using actionfunction. To pass a list to controller you can consider using Remoting(Stateless).

If you want to send a list of Ids you can always send a csv formatted string using js Something like

<script>
    UpdateSelected('a1we00000004EXAAA2,a1we00000004EXBAA2');
</script>
<apex:actionfunction name="UpdateSelected" action="{!TestAction}" rerender="r"> 
    <apex:param name="ids" value="" assignTo="{!SelectedIds}" /> 
</apex:actionfunction> 

and in the controller method you can split the string into list by

Example :

public String SelectedIds{get;set;}
public void TestAction(){
 List<String> allIds = SelectedIds.split(',');
}
  • Didn't realize that it wasn't even possible. Thanks! – Matt K Mar 6 '13 at 22:13

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.