I am trying to get the values from javascript
which is in array, to the apex controller and later save it.
When I check the debug logs, I see null value in it. Need help. Below is my code. I tried various methods available at the controller end, but luck. Below is the code for VF, JS & Apex.
VF code I have:-
<apex:form>
<apex:actionFunction action="{!saveAccountIds}" name="sendAccountIds">
<apex:param name="accountIds" value=""/>
</apex:actionFunction>
</apex:form>
JavaScript Code:-
_getAccountsList: function()
{
varaccountIds = [];
if (this.mainDirectionDiv.children.length > 0 && this.mainDirectionDiv.children[0].children.length > 0)
{
varliChildren = this.mainDirectionDiv.children[0].children;
for (i = 0; i < liChildren.length; i++)
{
accountIds.push(liChildren[i].getAttribute("liAccountId"));
}
console.log(accountIds);
}
sendAccountIds(accountIds);
}
Controller end:-
public void saveAccountIds()
{
List<String> Id = (List<String>) (Apexpages.currentPage().getParameters().get('accountIds'), List<String>.class);
Id.add(Apexpages.currentPage().getParameters().get('accountIds'));
System.debug('>>>>>>>>>>>>> HERE IS THE VALUE --> ' + Id);
}
When I check the debug logs, i see as
>>>>>>>>>>>>> HERE IS THE VALUE --> null
Once I confirm it in the debug logs, I can later think of pushing it in the object or wherever. Null value seems to be a major problem for me right now.