サーバー側の Apex コントローラークラスを作成する
はじめに
Lightning コンポーネントフレームワークは、モバイルデバイスとデスクトップデバイスに対応した動的な Web アプリケーションを開発するための UI フレームワークです。
このクイックスタートでは、組織の取引先責任者のリストを表示する簡単な Lightning コンポーネントを作成します。最初に Apex コントローラークラスを作成し、次に Lightning コンポーネントとイベントハンドラーを作成して、最後にコンポーネントで取引先責任者のリストを表示します。
Trail Together の動画
エキスパートの説明を見ながらこのステップを進めて行きたい場合は、 Trail Together シリーズの一部である、こちらの動画をご覧ください。
Apex コントローラーを作成する
クラスを作成して、取引先責任者のデータにアクセスします。
- Trailhead Playground で、設定歯車
をクリックし、[Developer Console (開発者コンソール)] を選択します。
-
[File (ファイル)] | [New (新規)] | [Apex Class (Apex クラス)] の順に選択します。
- クラス名として、
MyContactListControllerと入力し、[OK]をクリックします。
- In the body of the class (i.e. between the
{}braces), enter the following code Tip: You can copy and paste any code snippet from Trailhead by clicking Copy in the top right corner.Apex methods designated @AuraEnabled are able to be called from a Lightning component.@AuraEnabled public static List<Contact> getContacts(Id recordId) { return [SELECT Id, FirstName, LastName, Email, Phone FROM Contact WHERE AccountId = :recordId]; }
-
[File (ファイル)] | [Save (保存)] を選択します。
