function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
anuragsinghnsanuragsinghns 

Custom Component unable to call controller method form command button

Hi ,
I have a custom component and I have a button in the component it does not call the action emthod it is supposed to when clicked.

/My component /
<apex:component controller="myCOntroller" id="theComponent" allowDML="true">
<apex:commandButton value="Cancel" action="{!cancelDomain}" reRender="DomainSection" >
</apex:component>

/my contoller method/ 
public void cancelDomain() {
    system.debug('Test');
    }


I am unable to figure out why the action method does not get called any help would be appreciated.

Tejas KardileTejas Kardile
Hi,

Below is working code:
VF Component:
<apex:component controller="myCOntroller1" id="theComponent" allowDML="true">
<apex:commandButton value="Cancel" action="{!cancelDomain}" reRender="DomainSection" />
<div id="DomainSection"> Test</div>
</apex:component>

Apex class
public class myCOntroller1{
public void cancelDomain() {
    system.debug('11111111111111111Test');
    }
}

VF Page
<apex:page id="thePage">
 <apex:form >
  <c:Test_Comp />
 </apex:form>   
</apex:page>

Thanks