No Results
Search Tips:
- Please consider misspellings
- Try different search keywords
カスタムコントローラの作成
対応付けアプリケーションを作成するには、まず、マップおよび対応する取引先のリストを表示する Visualforce ページで参照されるカスタムコントローラを作成する必要があります。このコントローラでは、評価が「見込み有り」のユーザの取引先を取得して、Visualforce ページで対応付けを行う JavaScript ルーチンで使用するための、区切り文字で区切られた取引先の文字列配列を作成します。さらに、Salesforce ページで Google マップを使用するために必要な Maps API キーの getter メソッドも定義します。
次の Apex クラスは、ユーザの「見込み有り」の取引先を対応付ける Visualforce ページのコントローラです。
1swfobject.registerObject("clippy.codeblock-0", "9");public class mapController {
2
3 public String addrStr;
4 public User usr;
5 public String myKey;
6
7 public Account[] getMyAccts() {
8 String usrId = UserInfo.getUserId();
9 Account[] accts = [Select Id, Name, Rating, CustomerPriority__c,
10 OwnerId, BillingStreet, BillingCity, BillingState,
11 BillingPostalCode
12 From Account
13 where Rating = 'Hot'
14 And OwnerId =: usrId ];
15
16 for(Account acct : accts) {
17 addrStr = addrStr + acct.Name + ' : '
18 + acct.CustomerPriority__c + ':'
19 + acct.Id + '~:~'+ acct.BillingStreet + '~:~'
20 + acct.BillingCity + '~:~' + acct.BillingState + '~:~'
21 + acct.BillingPostalCode + '~::~';
22 }
23
24 return accts;
25 }
26
27 public String getmyKey() { // Set up google maps api key
28 myKey = 'http://maps.google.com/maps?file=api&v=2&';
29
30 // In the following line, enter your google maps key
31 // to get an api key, visit the Google Maps API site
32 // http://code.google.com/apis/maps/signup.html
33 myKey = myKey + 'key=<insert_google_maps_api_key_here>';
34
35 return myKey;
36 }
37
38 public String getAddrArStr(){
39 addrStr = '';
40 Account[] theRecs = getMyAccts();
41
42 return addrStr;
43 }
44
45}
46