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
jaisri devijaisri devi 

how to do execution in apex class for mycontrollerextension

Naveen KNNaveen KN
Hi Jaisri, appreciate if you could add more details describing the problem statement. 

Naveen
Raj VakatiRaj Vakati

The Execute Anonymous Apex tool in the Developer Console runs the Apex code you enter using ExecuteAnonymousand generates a debug log with the results of the execution.

Refer this link 

https://help.salesforce.com/articleView?id=code_dev_console_execute_anonymous.htm&type=5

Lets support this is your class  
 
public class myControllerExtension {

    private final Account acct;
    
    // The extension constructor initializes the private member
    // variable acct by using the getRecord method from the standard
    // controller.
    public myControllerExtension(ApexPages.StandardController stdController) {
        this.acct = (Account)stdController.getRecord();
    }

    public String getGreeting() {
        return 'Hello ' + acct.name + ' (' + acct.id + ')';
    }
}

You can execute the  Execute Anonymous Apex tool in the Developer Console as shown below
 
Account acc= new Account();
acc.Name='test' ;
insert acc ; 
ApexPages.StandardController stdAcc = new ApexPages.StandardController(acc);
myControllerExtension  extes=new myControllerExtension(stdAcc);
extes.getGreeting();



From Vf page like below ..
 
<apex:page standardController="Account" extensions="myControllerExtension">
    {!greeting} <p/>
    <apex:form>
        <apex:inputField value="{!account.name}"/> <p/>
        <apex:commandButton value="Save" action="{!save}"/>
    </apex:form>
</apex:page>

 
jaisri devijaisri devi
{!a.name} how to do a output?