この文章は Salesforce 機械翻訳システムを使用して翻訳されました。詳細はこちらをご参照ください。
英語に切り替える

カスタムコントローラの作成

対応付けアプリケーションを作成するには、まず、マップおよび対応する取引先のリストを表示する Visualforce ページで参照されるカスタムコントローラを作成する必要があります。このコントローラでは、評価が「見込み有り」のユーザの取引先を取得して、Visualforce ページで対応付けを行う JavaScript ルーチンで使用するための、区切り文字で区切られた取引先の文字列配列を作成します。さらに、Salesforce ページで Google マップを使用するために必要な Maps API キーの getter メソッドも定義します。

次の Apex クラスは、ユーザの「見込み有り」の取引先を対応付ける Visualforce ページのコントローラです。

1swfobject.registerObject("clippy.codeblock-0", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17public class mapController {
18
19   public String addrStr;
20   public User usr;
21   public String myKey;
22
23   public Account[] getMyAccts() {
24      String usrId = UserInfo.getUserId();
25      Account[] accts = [Select Id, Name, Rating, CustomerPriority__c, 
26                         OwnerId, BillingStreet, BillingCity, BillingState, 
27                         BillingPostalCode
28                         From Account 
29                         where Rating = 'Hot'
30                         And OwnerId =: usrId ];
31                            
32      for(Account acct : accts) {            
33         addrStr = addrStr + acct.Name + ' : ' 
34                   + acct.CustomerPriority__c  + ':' 
35                   + acct.Id + '~:~'+ acct.BillingStreet + '~:~' 
36                   + acct.BillingCity + '~:~' +  acct.BillingState + '~:~' 
37                   + acct.BillingPostalCode + '~::~';		
38      }
39
40      return accts;     
41   }
42    
43   public String getmyKey() {  // Set up google maps api key
44      myKey = 'http://maps.google.com/maps?file=api&v=2&';
45
46      // In the following line, enter your google maps key
47      // to get an api key, visit the Google Maps API site
48      // http://code.google.com/apis/maps/signup.html
49      myKey = myKey + 'key=<insert_google_maps_api_key_here>';
50
51      return myKey;
52   }
53    
54   public String getAddrArStr(){
55      addrStr = '';
56      Account[] theRecs = getMyAccts();
57
58      return addrStr;	
59   }
60
61}
62