I have a custom VF component that gets passed in an ApexPages.Action (=passedInAction()) that needs to be invoked when the user performs some changes inside the component (=doInvokeAction() method).
My problem is that the passed in action always is null when it's going to be invoked. What is that so?
Component markup:
<apex:component controller="ComponentCtrl" allowDML="true">
<apex:attribute name="onAction" assignTo="{!passedInAction}" type="ApexPages.Action" required="false" description="" />
<apex:attribute name="rerenderOnPage" type="String" required="false" description="" />
...
<apex:inputCheckbox...>
<apex:actionSupport event="onclick" action="{!doInvokeAction}" rerender="componentIds,{!rerenderOnPage}" />
</apex:inputCheckbox>
...
</apex:component>
Component controller:
public with sharing class ComponentCtrl {
public ApexPages.Action passedInAction { get; set; }
...
public PageReference doInvokeAction() {
someInternalComponentsStuff()
return passedInAction.invoke(); <--- NULLPOINTER HERE!
}
}
VF Page using the component and passing in its Action:
<apex:page standardController="CustomObject__c" extensions="PageCtrlExt" recordSetVar="dlis" sidebar="false">
...
<apex:form id="form">
<c:myComponent onSelect="{!actionToPassIn}"
rerenderOnSelect="selectedItem" />
</apex:form>
</apex:page>
VF Page Controller Extension:
public with sharing class PageCtrlExt {
...
public PageReference actionToPassIn() {
....
return null;
}
}