Create an Apex Controller Class in the Force.com IDE
Create a class to access data from contacts.
- If you don’t already have an Eclipse project for this org, complete the steps in Create a Force.com Project.
-
To save changes to the server automatically, right-click
the name of the project that you created, then select .
When Work Online is enabled, the icon next to your
project name looks like this:
, rather than like this:
.
Working online can lead to long save times, but your Developer Edition org probably has a
small codebase, so save times aren’t a concern.
- Right-click your project in the Package Explorer, then select .
- Enter MyContactListController in the Name field, and then click Finish.
-
In the body of the class, between the {} braces, enter this code.
1@AuraEnabled 2 public static List<Contact> getContacts() { 3 return [SELECT Id, Name, Email, Title, Phone FROM Contact]; 4 }@AuraEnabled enables client- and server-side access to the controller method.
- To save your updated class, press Ctrl+S or (Cmd+S on macOS).