I have VF Component and component controller. I am trying to call action method incomponent controller from component and receiving unknown property error. Please see below,
Controller
public class ComponentNewController {
public ComponentNewController()
{
}
public CustomObj__c myRequest;
public void setMyRequest (CustomObj__c s) {
myRequest= s;
}
public CustomObj__c getMyRequest() {
return myRequest;
}
public void onClickAction()
{
if(myRequest.customfield__c)
{
myRequest.customfield__c = true;
}
}
}
Component
<apex:component controller="ComponentNewController">
<apex:attribute name="attr" description="Request object" type="CustomObj__c" assignTo="{!myRequest}"/>
<apex:outputPanel id="OuterPanel">
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:outputLabel value="Escalate?"></apex:outputLabel>
<apex:inputField value="{!attr.customfield__c}">
<actionSupport event="onchange" action="{!onClickAction}" rerender="OuterPanel" />
</apex:inputField>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputPanel >
<apex:outputLabel rendered="{!attr.customfield__c == true}" > Notes</apex:outputLabel>
</apex:outputPanel>
<apex:outputPanel >
<apex:inputField rendered="{!attr.customfield__c == true}" value="{!attr.Notes__c}" />
</apex:outputPanel>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:outputPanel>
</apex:component>
When I try to save the file I receive error:
Unknown property: ComponentNewController.OnclickAction
If I comment below line - no error is shown
<actionSupport event="onchange" action="{!onClickAction}" rerender="OuterPanel" />
Can anyone explain why this error is shown ?
actionSupport
toapex:actionSupport
so Visualforce looks for theaction
attribute to reference a method not property.{! ... }
is used it is assumed to be a property i.e. a getter for the value is needed.