Apex RemoteAction アノテーションのサンプル

環境
Salesforce

説明
RemoteAction アノテーションでは、Visualforce で使用する Apex メソッドの JavaScript を介したコールのサポートが提供されます。
このプロセスは、多くの場合 JavaScript Remoting と呼ばれます。
RemoteAction アノテーションのあるメソッドは、static、かつ global または public である必要があります。

使用例
1.Apex クラスをカスタムコントローラまたはコントローラ拡張としてページに追加します。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<apex:page controller="MyController" extension="MyExtension">
<apex:page controller="MyController" extension="MyExtension">
<apex:page controller="MyController" extension="MyExtension">

2.JavaScript Remotingを使用する Visualforceページには、すべての標準Visualforceの制限が適用されます。
サンプルコード

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
public with sharing class RemoteActionController{
@RemoteAction
public static String getRecord(String strParam) {
String response = 'xxx';
return response;
}
}
public with sharing class RemoteActionController{ @RemoteAction public static String getRecord(String strParam) { String response = 'xxx'; return response; } }
public with sharing class RemoteActionController{
  @RemoteAction
  public static String getRecord(String strParam) {
    String response = 'xxx';
    return response;
  }
}

 

Apex

Posted by arkgame