SlideShare uma empresa Scribd logo
1 de 34
Baixar para ler offline
Visualforce + jQuery
Force.com上でjQueryを有効活用
Riezel Ramos, Salesforce.com, Associate Sales Support Engineer
Kaz Kawamura, Salesforce.com, Technical Solution Architect
Safe harbor
 Safe harbor statement under the Private Securities Litigation Reform Act of 1995:

 This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties
 materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results
 expressed or implied by the forward-looking statements we make. All statements other than statements of historical fact could be
 deemed forward-looking, including any projections of product or service availability, subscriber growth, earnings, revenues, or other
 financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any
 statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services.

 The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new
 functionality for our service, new products and services, our new business model, our past operating losses, possible fluctuations in our
 operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of
 intellectual property and other litigation, risks associated with possible mergers and acquisitions, the immature market in which we
 operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new
 releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization
 and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com,
 inc. is included in our annual report on Form 10-Q for the most recent fiscal quarter ended July 31, 2012. This documents and others
 containing important disclosures are available on the SEC Filings section of the Investor Information section of our Web site.

 Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently
 available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based
 upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-
 looking statements.
今日の内容

・Javascript + jQuery
・Javascript + jQuery + Visualforce
・Javascript + jQuery + Visualforce + Imagination
自己紹介
ライゼール ラモス (Riezel Ramos)	
   河村 嘉之(Kaz Kawamura)	
・出身: フィリピン                   ・会社: Salesforce.com
・会社: Salesforce.com          ・仕事: Technical Solution Architect
・仕事: Sales Support       
Engineer                     	
・その他名前: ライズ、ライコ、雷子                                    この本の著者
Javascript + jQuery
Javascriptのないインターネット	
                       ・Facebook : メッセージとチャットが動かない	
・Youtube: ビデオが動かない	




                       ・Twitter : Tweetできない	



・地図: 検索にリダイレクトされる
Javascriptがあるから、ウェブがインターアクティブになった
Javascriptの役割:HTMLドキュメントを操作するため	
      ウェブページ	
                         <body>
                                     <div>
                                               <input  type=“text”  id=“in1”/>
      HTML: 構造	
                     </div>
                         </body>
                         
                         <script  type=“text/javascript”>
                                   var  foo  =  document.getElementById(“in1”);
   Javascript: アクション	
           foo.addEventListener(“click”,  alert(“アロハ!”),  false);
                         </script>
                         
                         
                         <style>
                                   body{
      CSS: スタイル	
                              background:  pink;
                                   }
                         </style>
問題:JavascriptだけでDOMの操作が難しい!	




                      よく使うJavascriptの機
                      能をいくつまとめて、提
                      供しています。
jQueryでJavascriptをシンプルにする	

Javascript	
                        jQuery	


var x =                             var x = $(‘#in1');
document.getElementById(‘in1’);	

                                    サンプル:http://jquery.com/
jQueryの良い点	


・32KB (minified)   ・jQuery UI
・CSS3のサポート         ・jQuery Mobile
・クロスブラウザーサポート	
    ・jQuery Plugins
Javascript + jQuery +
force.com
まずは、jQueryライブラリをVFページから読みましょう
 ・静的リソースとして、アップロード
   <script src=“{!$Resource.jQueryFile}”></script>
 ・CDNを使う
   <script src=“https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js”></script>
Apex:includeScript OR script?	
<apex:page showHeader="false">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>

  <apex:includeScript value="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.2/jquery.min.js"/>
</apex:page>
気を付けましょう!
$j = jQuery.noConflict();
 →他のライブラリとconflictしないため(標準Visualforceで使っているライブラリを含む)
Visualforce v.s. jQuery	




         Visualforce	
      jQuery	

ページ	
                                  部品
Visualforce > jQuery	
          ボタンを押した時の
           アクションなどを
                            基本はVFで
          JavaScriptで記述	
   書いたページ
Visualforceの部品のIDを取るには?	
                                                          階層がある場合は
                                                            階層も指定	
                                        !$Component.コン
<apex:outputPanel   id="thePanel"></apex:outputPanel>	
                                       ポーネントのIDを指定	



      document.getElementById("{!
      $Component.thePanel}").innerHTML = result;	
                                  j_id0:thePanel

      $("#{!
      $Component.thePanel}").text(res
      ult);	
         注意!
                                IDに:が入ると
                      これは動かない	
                                    jQueryは別の      実はjQueryとVFの
                                     意味に捉える	
      相性はあまり良くな
                                                    い…(以下略)
Visualforce+jQuery 使いどころ	

                                           生成されるコードでは
                                            class属性になる	
 <apex:form >
  Weekday <apex:inputCheckBox value="{!weekday}" styleClass="days"/>
  Satday <apex:inputCheckBox value="{!satday}" styleClass="days"/>
  Sunday <apex:inputCheckBox value="{!sunday}" styleClass="days"/>
  <input type="button" id="check" value="check all"/>
</apex:form>	
                               $('#check').click(function() {
                                 $('.days').attr('checked', 'checked');
                               });	
                                     classを指定して
                                        一括処理	
                       UIに+αを加える
Visualforce < jQuery	



                         サーバサイドの
                         機能を呼び出し	




           ほぼHTMLで
           そのまま記述
ページからforce.comにアクセス	

 • actionSupport
 • actionFunction
 • JavaScript Remoting
actionSupport	
                                      コントローラ
                                      のメソッドを
                                                        イベントを
                                       呼び出す	
            指定	
 <apex:inputText value="{!recordInputText}">
   <apex:actionSupport action="{!refresh}" event="onchange”
                       reRender="parentPanel">
     <apex:param assignTo="{!var1}" value="{!recordId}"
                 name="recordParam"/>
   </apex:actionSupport>
 </apex:inputText>

 イベントの発生に合わせて、コントローラのメソッドを呼び出す
 • JavaScriptを書かずにイベント処理を実現
 • 結果はreRenderで
actionFunction	
                             コントローラの
            名前を
                             メソッドを指定	
            付ける	

<apex:actionFunction action="{!methodOne}"
      name="methodOneInJavascript" rerender="showstate">
  <apex:param name="firstParam" assignTo="{!state}" value="" 指定した名前で
                                                              />
</apex:actionFunction>                                       JavaScriptから
                                                                呼び出し	
                                             <script>
                                               function clickOne(){
                                                 methodOneInJavaScript();
                                               }
                                             </script>

          コントローラのメソッドに名前を付けてJavaScriptから利用できるようにする
          • 結果はreRenderで
JavaScript Remoting	
     コントローラ名.メソッド名で
          呼び出し	
        引数を
  <script>              渡せる	
       コールバック関数	
  $(function() {
    HelloRemote.sayHello('World', function(result, event) {
      $('#out').text(result);
    });
  });
  </script>           global class HelloRemote {
                          @RemoteAction
                          global static String sayHello(String name) {
           リモートアクセス可能な
           メソッドをアノテーション     return 'Hello ' + name + '!';
               でマーク	
     }
                      }	
             よりJavaScriptっぽくコントローラのメソッドを呼べる
             • より柔軟
             • ただしコードは増える
IDの工夫	


<apex:page standardController="Account” recordSetVar="accounts">
<apex:repeat value="{!accounts}" var="account">
    <div id=”acct_{!account.id}">{!account.name}</div>
</apex:repeat>
</apex:page> SFIDをうまく活用
             すると一意性を確   <div id=”acct_001A00000090CmoIAE">A商事</div>
             保するのが容易	
  <div id=”acct_001A000000RQgHkIAL”>B商事</div>
                        <div id=”acct_001A000000EaawzIAB">A商事</div>
                               IDは一意で
                               なければいけ
                                  ない
Javascript + jQuery +
Visualforce + Imagination
世界征服をしてやろう!!
Mini Page Hover               デモ




 ・レコード名にhoverをしたら、詳細を表示する
Mini Page Hover: コード
 var url = $(this).attr(‘href’) + ‘ div.bDetailBlock’;   //hoverしているレコードのURLを取得


 $(‘#overlay’).load(url, function () {                   //#overlayのdivにURLをロードする
       setTimeout(function () {                          //overlayを表示する
         $(‘#overlay’).show(); },
       200);
 });
Mini Page Hover: コード
 アドバイス:
 HTMLで作られているホームページコンポーネントのコードフォーマットが崩れるため、jsbeautifierみたいなツールを使うのがお
 勧めです (http://jsbeautifier.org/)
デモ	
  iPad アンケート作成用ツール             デモ(iPad)	
セールスフォース側	




                     iPad側
iPad アンケート作成用ツール(セールスフォース側)
・jQuery + jQuery UI

$( ".answerUL1" ).sortable({
   start: function (e, ui) { },
   update: function (e, ui) {               /*更新時にこのメッソドを行う */
        $( “.answerUL .choiceLabel1”).each( function(){ /* 各選択肢のソート番号を更新する */
              $(this).find(".choiceSortNumber").val($(this).index()+1);
        });
         /* apexコントローラーを呼び出し、ソート番号を更新する */
         sortChoiceList( /*パラメータ省略 */);
} });
<apex:actionFunction action="{!sortChoiceList}" reRender="questionPanel" name="sortChoiceList"
oncomplete="initSortable();" >
          /* パラメータ省略 */
</apex:actionFunction>
iPad アンケート作成用ツール(セールスフォース側)	
アドバイス:
reRenderの使い方
ページの一部のみ、更新したい場合、
reRenderでapexタグのidを指定すれば、
指定したDOMしか更新されません。


reRenderを使う時に、できるだけ小さいDOMを
設定しないと、重くなる可能性があります。


<apex:actionFunction action="{!sortChoiceList}"
          reRender="questionPanel"
          name="sortChoiceList"
          oncomplete="initSortable();" />
                                                  選択肢の順番を更新したいため、選択肢
                                                  を持っているパネルを更新します。全ペー
                                                  ジを更新したら、重くなりますので、小さい
                                                  範囲で更新したほうが良いです。
iPad アンケート作成用ツール(iPad側)	
・jQuery + jQuery Mobile
・複数のプラットフォームで見えるページを
モバイル向けのUIで簡単に作成ができるので、
jQuery Mobileで作りました。



             apex:repeatでページ、
             質問、選択肢を
             ループして表示している
Visualforce + jQuery

Mais conteúdo relacionado

Mais procurados

What is a Data Warehouse and How Do I Test It?
What is a Data Warehouse and How Do I Test It?What is a Data Warehouse and How Do I Test It?
What is a Data Warehouse and How Do I Test It?
RTTS
 

Mais procurados (20)

1. 아키텍쳐 설계 프로세스
1. 아키텍쳐 설계 프로세스1. 아키텍쳐 설계 프로세스
1. 아키텍쳐 설계 프로세스
 
3. 마이크로 서비스 아키텍쳐
3. 마이크로 서비스 아키텍쳐3. 마이크로 서비스 아키텍쳐
3. 마이크로 서비스 아키텍쳐
 
[웨비나] 클라우드 마이그레이션 수행 시 가장 많이 하는 질문 Top 10!
[웨비나] 클라우드 마이그레이션 수행 시 가장 많이 하는 질문 Top 10![웨비나] 클라우드 마이그레이션 수행 시 가장 많이 하는 질문 Top 10!
[웨비나] 클라우드 마이그레이션 수행 시 가장 많이 하는 질문 Top 10!
 
IBM DB2 for zOSのソースエンドポイントとしての利用
IBM DB2 for zOSのソースエンドポイントとしての利用IBM DB2 for zOSのソースエンドポイントとしての利用
IBM DB2 for zOSのソースエンドポイントとしての利用
 
【旧版】Oracle Gen 2 Exadata Cloud@Customer:サービス概要のご紹介 [2021年12月版]
【旧版】Oracle Gen 2 Exadata Cloud@Customer:サービス概要のご紹介 [2021年12月版]【旧版】Oracle Gen 2 Exadata Cloud@Customer:サービス概要のご紹介 [2021年12月版]
【旧版】Oracle Gen 2 Exadata Cloud@Customer:サービス概要のご紹介 [2021年12月版]
 
What is a Data Warehouse and How Do I Test It?
What is a Data Warehouse and How Do I Test It?What is a Data Warehouse and How Do I Test It?
What is a Data Warehouse and How Do I Test It?
 
Salesforceのソースエンドポイントとしての利用
Salesforceのソースエンドポイントとしての利用Salesforceのソースエンドポイントとしての利用
Salesforceのソースエンドポイントとしての利用
 
Power BI Advance Modeling
Power BI Advance ModelingPower BI Advance Modeling
Power BI Advance Modeling
 
[2018] 고객 사례를 통해 본 클라우드 전환 전략
[2018] 고객 사례를 통해 본 클라우드 전환 전략[2018] 고객 사례를 통해 본 클라우드 전환 전략
[2018] 고객 사례를 통해 본 클라우드 전환 전략
 
Azure Datalake 大全
Azure Datalake 大全Azure Datalake 大全
Azure Datalake 大全
 
Oracle archi ppt
Oracle archi pptOracle archi ppt
Oracle archi ppt
 
Oracle Database Applianceのご紹介(詳細)
Oracle Database Applianceのご紹介(詳細)Oracle Database Applianceのご紹介(詳細)
Oracle Database Applianceのご紹介(詳細)
 
SQL Server Upgrade and Consolidation - Methodology and Approach
SQL Server Upgrade and Consolidation - Methodology and ApproachSQL Server Upgrade and Consolidation - Methodology and Approach
SQL Server Upgrade and Consolidation - Methodology and Approach
 
11 Understanding and Influencing the PL/SQL Compilar
11 Understanding and Influencing the PL/SQL Compilar11 Understanding and Influencing the PL/SQL Compilar
11 Understanding and Influencing the PL/SQL Compilar
 
Power bi
Power biPower bi
Power bi
 
4. 대용량 아키텍쳐 설계 패턴
4. 대용량 아키텍쳐 설계 패턴4. 대용량 아키텍쳐 설계 패턴
4. 대용량 아키텍쳐 설계 패턴
 
【de:code 2020】 今すぐはじめたい SQL Database のかしこい使い分け術 後編
【de:code 2020】 今すぐはじめたい SQL Database のかしこい使い分け術 後編【de:code 2020】 今すぐはじめたい SQL Database のかしこい使い分け術 後編
【de:code 2020】 今すぐはじめたい SQL Database のかしこい使い分け術 後編
 
Présentation Oracle DataBase 11g
Présentation Oracle DataBase 11gPrésentation Oracle DataBase 11g
Présentation Oracle DataBase 11g
 
みんな大好き!!ファイルサーバー DFS-R vs S2D
みんな大好き!!ファイルサーバー DFS-R vs S2Dみんな大好き!!ファイルサーバー DFS-R vs S2D
みんな大好き!!ファイルサーバー DFS-R vs S2D
 
Power BI - Row Level Security
Power BI - Row Level SecurityPower BI - Row Level Security
Power BI - Row Level Security
 

Semelhante a Visualforce + jQuery

勉強会force#2 HTML5によるモバイルアプリ開発
勉強会force#2 HTML5によるモバイルアプリ開発勉強会force#2 HTML5によるモバイルアプリ開発
勉強会force#2 HTML5によるモバイルアプリ開発
Kazuki Nakajima
 
JavaFX 2.0 - リッチクライアントのためのUI基盤
JavaFX 2.0 - リッチクライアントのためのUI基盤JavaFX 2.0 - リッチクライアントのためのUI基盤
JavaFX 2.0 - リッチクライアントのためのUI基盤
Yuichi Sakuraba
 
Jqm20120210
Jqm20120210Jqm20120210
Jqm20120210
cmtomoda
 
20110714 j queryベーシック
20110714 j queryベーシック20110714 j queryベーシック
20110714 j queryベーシック
良太 増子
 
Tech talk salesforce mobile sdk
Tech talk   salesforce mobile sdkTech talk   salesforce mobile sdk
Tech talk salesforce mobile sdk
Kazuki Nakajima
 
Lighting componentワークブック(経費精算アプリ)
Lighting componentワークブック(経費精算アプリ)Lighting componentワークブック(経費精算アプリ)
Lighting componentワークブック(経費精算アプリ)
Akihiro Iwaya
 
html5j.orgがHTML5+JavaScriptで Metro Style アプリを作ってみた
html5j.orgがHTML5+JavaScriptで Metro Style アプリを作ってみた html5j.orgがHTML5+JavaScriptで Metro Style アプリを作ってみた
html5j.orgがHTML5+JavaScriptで Metro Style アプリを作ってみた
Shumpei Shiraishi
 
今からでも遅くない! React事始め
今からでも遅くない! React事始め今からでも遅くない! React事始め
今からでも遅くない! React事始め
ynaruta
 
Twitter連携chrome extension作り方
Twitter連携chrome extension作り方Twitter連携chrome extension作り方
Twitter連携chrome extension作り方
Hiroshi Oyamada
 

Semelhante a Visualforce + jQuery (20)

勉強会force#2 HTML5によるモバイルアプリ開発
勉強会force#2 HTML5によるモバイルアプリ開発勉強会force#2 HTML5によるモバイルアプリ開発
勉強会force#2 HTML5によるモバイルアプリ開発
 
CodeIgniterによるPhwittr
CodeIgniterによるPhwittrCodeIgniterによるPhwittr
CodeIgniterによるPhwittr
 
JavaFX 2.0 - リッチクライアントのためのUI基盤
JavaFX 2.0 - リッチクライアントのためのUI基盤JavaFX 2.0 - リッチクライアントのためのUI基盤
JavaFX 2.0 - リッチクライアントのためのUI基盤
 
From Swing to JavaFX - SwingからJavaFXへのマイグレーションガイド
From Swing to JavaFX  - SwingからJavaFXへのマイグレーションガイドFrom Swing to JavaFX  - SwingからJavaFXへのマイグレーションガイド
From Swing to JavaFX - SwingからJavaFXへのマイグレーションガイド
 
Jqm20120210
Jqm20120210Jqm20120210
Jqm20120210
 
20110714 j queryベーシック
20110714 j queryベーシック20110714 j queryベーシック
20110714 j queryベーシック
 
jQuery と MVC で実践する標準志向 Web 開発
jQuery と MVC で実践する標準志向 Web 開発jQuery と MVC で実践する標準志向 Web 開発
jQuery と MVC で実践する標準志向 Web 開発
 
Tech talk salesforce mobile sdk
Tech talk   salesforce mobile sdkTech talk   salesforce mobile sdk
Tech talk salesforce mobile sdk
 
Knockout
KnockoutKnockout
Knockout
 
ソーシャルアプリ勉強会(第一回資料)配布用
ソーシャルアプリ勉強会(第一回資料)配布用ソーシャルアプリ勉強会(第一回資料)配布用
ソーシャルアプリ勉強会(第一回資料)配布用
 
Ajax 応用
Ajax 応用Ajax 応用
Ajax 応用
 
Lighting componentワークブック(経費精算アプリ)
Lighting componentワークブック(経費精算アプリ)Lighting componentワークブック(経費精算アプリ)
Lighting componentワークブック(経費精算アプリ)
 
Webに今求められているレベル: HTML5 コントロールを利用した開発
Webに今求められているレベル: HTML5 コントロールを利用した開発Webに今求められているレベル: HTML5 コントロールを利用した開発
Webに今求められているレベル: HTML5 コントロールを利用した開発
 
Magento meet up Tokyo#1 for Design
Magento meet up Tokyo#1 for DesignMagento meet up Tokyo#1 for Design
Magento meet up Tokyo#1 for Design
 
html5j.orgがHTML5+JavaScriptで Metro Style アプリを作ってみた
html5j.orgがHTML5+JavaScriptで Metro Style アプリを作ってみた html5j.orgがHTML5+JavaScriptで Metro Style アプリを作ってみた
html5j.orgがHTML5+JavaScriptで Metro Style アプリを作ってみた
 
Jquery1 1
Jquery1 1Jquery1 1
Jquery1 1
 
今からでも遅くない! React事始め
今からでも遅くない! React事始め今からでも遅くない! React事始め
今からでも遅くない! React事始め
 
何が変わった JavaFX 2.0
何が変わった JavaFX 2.0何が変わった JavaFX 2.0
何が変わった JavaFX 2.0
 
jQuery超入門編
jQuery超入門編jQuery超入門編
jQuery超入門編
 
Twitter連携chrome extension作り方
Twitter連携chrome extension作り方Twitter連携chrome extension作り方
Twitter連携chrome extension作り方
 

Mais de Salesforce Developers Japan

データ連携の新しいカタチ - 変更データキャプチャ/プラットフォームイベントを MuleSoft Anypoint Platform と組み合わせて試してみよう
データ連携の新しいカタチ - 変更データキャプチャ/プラットフォームイベントを MuleSoft Anypoint Platform と組み合わせて試してみようデータ連携の新しいカタチ - 変更データキャプチャ/プラットフォームイベントを MuleSoft Anypoint Platform と組み合わせて試してみよう
データ連携の新しいカタチ - 変更データキャプチャ/プラットフォームイベントを MuleSoft Anypoint Platform と組み合わせて試してみよう
Salesforce Developers Japan
 
業務課題の解決に、データ分析・予測結果の活用を - Einstein Discovery / Einstein 予測ビルダーのご紹介 -
業務課題の解決に、データ分析・予測結果の活用を - Einstein Discovery / Einstein 予測ビルダーのご紹介 -業務課題の解決に、データ分析・予測結果の活用を - Einstein Discovery / Einstein 予測ビルダーのご紹介 -
業務課題の解決に、データ分析・予測結果の活用を - Einstein Discovery / Einstein 予測ビルダーのご紹介 -
Salesforce Developers Japan
 

Mais de Salesforce Developers Japan (20)

Salesforce DX の始め方とパートナー様成功事例
Salesforce DX の始め方とパートナー様成功事例Salesforce DX の始め方とパートナー様成功事例
Salesforce DX の始め方とパートナー様成功事例
 
データ連携の新しいカタチ - 変更データキャプチャ/プラットフォームイベントを MuleSoft Anypoint Platform と組み合わせて試してみよう
データ連携の新しいカタチ - 変更データキャプチャ/プラットフォームイベントを MuleSoft Anypoint Platform と組み合わせて試してみようデータ連携の新しいカタチ - 変更データキャプチャ/プラットフォームイベントを MuleSoft Anypoint Platform と組み合わせて試してみよう
データ連携の新しいカタチ - 変更データキャプチャ/プラットフォームイベントを MuleSoft Anypoint Platform と組み合わせて試してみよう
 
Einstein Analyticsでのデータ取り込みと加工
Einstein Analyticsでのデータ取り込みと加工Einstein Analyticsでのデータ取り込みと加工
Einstein Analyticsでのデータ取り込みと加工
 
GMOペパボのエンジニアが語るHeroku活用ノウハウ
GMOペパボのエンジニアが語るHeroku活用ノウハウGMOペパボのエンジニアが語るHeroku活用ノウハウ
GMOペパボのエンジニアが語るHeroku活用ノウハウ
 
Salesforce Big Object 最前線
Salesforce Big Object 最前線Salesforce Big Object 最前線
Salesforce Big Object 最前線
 
Salesforce 開発者向け最新情報 Web セミナー 〜 TrailheaDX での新発表 & Summer '19 リリース新機能 〜
Salesforce 開発者向け最新情報 Web セミナー 〜 TrailheaDX での新発表 & Summer '19 リリース新機能 〜Salesforce 開発者向け最新情報 Web セミナー 〜 TrailheaDX での新発表 & Summer '19 リリース新機能 〜
Salesforce 開発者向け最新情報 Web セミナー 〜 TrailheaDX での新発表 & Summer '19 リリース新機能 〜
 
Einstein Next Best Action を試してみよう
Einstein Next Best Action を試してみようEinstein Next Best Action を試してみよう
Einstein Next Best Action を試してみよう
 
Salesforce DXとLightning Web ComponentsでモダンSalesforceアプリ開発
Salesforce DXとLightning Web ComponentsでモダンSalesforceアプリ開発Salesforce DXとLightning Web ComponentsでモダンSalesforceアプリ開発
Salesforce DXとLightning Web ComponentsでモダンSalesforceアプリ開発
 
Lightning時代のService Cloud概要とカスタマイズ
Lightning時代のService Cloud概要とカスタマイズLightning時代のService Cloud概要とカスタマイズ
Lightning時代のService Cloud概要とカスタマイズ
 
Spring '19リリース開発者向け新機能セミナー
Spring '19リリース開発者向け新機能セミナーSpring '19リリース開発者向け新機能セミナー
Spring '19リリース開発者向け新機能セミナー
 
業務課題の解決に、データ分析・予測結果の活用を - Einstein Discovery / Einstein 予測ビルダーのご紹介 -
業務課題の解決に、データ分析・予測結果の活用を - Einstein Discovery / Einstein 予測ビルダーのご紹介 -業務課題の解決に、データ分析・予測結果の活用を - Einstein Discovery / Einstein 予測ビルダーのご紹介 -
業務課題の解決に、データ分析・予測結果の活用を - Einstein Discovery / Einstein 予測ビルダーのご紹介 -
 
Einstein analyticsdashboardwebinar
Einstein analyticsdashboardwebinarEinstein analyticsdashboardwebinar
Einstein analyticsdashboardwebinar
 
MuleSoft Anypoint Platformのコンセプトとサービス
MuleSoft Anypoint PlatformのコンセプトとサービスMuleSoft Anypoint Platformのコンセプトとサービス
MuleSoft Anypoint Platformのコンセプトとサービス
 
IoTで成功を収めるための製品と戦略 〜 Salesforce IoT 〜
IoTで成功を収めるための製品と戦略 〜 Salesforce IoT 〜IoTで成功を収めるための製品と戦略 〜 Salesforce IoT 〜
IoTで成功を収めるための製品と戦略 〜 Salesforce IoT 〜
 
Heroku seminar winter19
Heroku seminar winter19Heroku seminar winter19
Heroku seminar winter19
 
Dreamforce18 update platform
Dreamforce18 update platformDreamforce18 update platform
Dreamforce18 update platform
 
Winter '19 開発者向け新機能
Winter '19 開発者向け新機能Winter '19 開発者向け新機能
Winter '19 開発者向け新機能
 
Lightning時代のレポート ダッシュボード & Flow 最前線
Lightning時代のレポート ダッシュボード & Flow 最前線Lightning時代のレポート ダッシュボード & Flow 最前線
Lightning時代のレポート ダッシュボード & Flow 最前線
 
Summer18 開発者向け新機能Webセミナー
Summer18 開発者向け新機能WebセミナーSummer18 開発者向け新機能Webセミナー
Summer18 開発者向け新機能Webセミナー
 
使ってみよう、Salesforce Big Object!
使ってみよう、Salesforce Big Object!使ってみよう、Salesforce Big Object!
使ってみよう、Salesforce Big Object!
 

Visualforce + jQuery

  • 1. Visualforce + jQuery Force.com上でjQueryを有効活用 Riezel Ramos, Salesforce.com, Associate Sales Support Engineer Kaz Kawamura, Salesforce.com, Technical Solution Architect
  • 2. Safe harbor Safe harbor statement under the Private Securities Litigation Reform Act of 1995: This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward-looking statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of product or service availability, subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services. The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our service, new products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of intellectual property and other litigation, risks associated with possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-Q for the most recent fiscal quarter ended July 31, 2012. This documents and others containing important disclosures are available on the SEC Filings section of the Investor Information section of our Web site. Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward- looking statements.
  • 3. 今日の内容 ・Javascript + jQuery ・Javascript + jQuery + Visualforce ・Javascript + jQuery + Visualforce + Imagination
  • 4. 自己紹介 ライゼール ラモス (Riezel Ramos) 河村 嘉之(Kaz Kawamura) ・出身: フィリピン ・会社: Salesforce.com ・会社: Salesforce.com ・仕事: Technical Solution Architect ・仕事: Sales Support        Engineer ・その他名前: ライズ、ライコ、雷子 この本の著者
  • 6. Javascriptのないインターネット ・Facebook : メッセージとチャットが動かない ・Youtube: ビデオが動かない ・Twitter : Tweetできない ・地図: 検索にリダイレクトされる
  • 8. Javascriptの役割:HTMLドキュメントを操作するため ウェブページ <body>            <div>                      <input  type=“text”  id=“in1”/> HTML: 構造            </div> </body> <script  type=“text/javascript”>          var  foo  =  document.getElementById(“in1”); Javascript: アクション        foo.addEventListener(“click”,  alert(“アロハ!”),  false); </script> <style>          body{ CSS: スタイル                      background:  pink;          } </style>
  • 9. 問題:JavascriptだけでDOMの操作が難しい! よく使うJavascriptの機 能をいくつまとめて、提 供しています。
  • 10. jQueryでJavascriptをシンプルにする Javascript jQuery var x = var x = $(‘#in1'); document.getElementById(‘in1’); サンプル:http://jquery.com/
  • 11. jQueryの良い点 ・32KB (minified) ・jQuery UI ・CSS3のサポート ・jQuery Mobile ・クロスブラウザーサポート ・jQuery Plugins
  • 12. Javascript + jQuery + force.com
  • 13. まずは、jQueryライブラリをVFページから読みましょう ・静的リソースとして、アップロード <script src=“{!$Resource.jQueryFile}”></script> ・CDNを使う <script src=“https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js”></script>
  • 14. Apex:includeScript OR script? <apex:page showHeader="false"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> <apex:includeScript value="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.2/jquery.min.js"/> </apex:page>
  • 16. Visualforce v.s. jQuery Visualforce jQuery ページ 部品
  • 17. Visualforce > jQuery ボタンを押した時の アクションなどを 基本はVFで JavaScriptで記述 書いたページ
  • 18. Visualforceの部品のIDを取るには? 階層がある場合は 階層も指定 !$Component.コン <apex:outputPanel id="thePanel"></apex:outputPanel> ポーネントのIDを指定 document.getElementById("{! $Component.thePanel}").innerHTML = result; j_id0:thePanel $("#{! $Component.thePanel}").text(res ult); 注意! IDに:が入ると これは動かない jQueryは別の 実はjQueryとVFの 意味に捉える 相性はあまり良くな い…(以下略)
  • 19. Visualforce+jQuery 使いどころ 生成されるコードでは class属性になる <apex:form > Weekday <apex:inputCheckBox value="{!weekday}" styleClass="days"/> Satday <apex:inputCheckBox value="{!satday}" styleClass="days"/> Sunday <apex:inputCheckBox value="{!sunday}" styleClass="days"/> <input type="button" id="check" value="check all"/> </apex:form> $('#check').click(function() { $('.days').attr('checked', 'checked'); }); classを指定して 一括処理 UIに+αを加える
  • 20. Visualforce < jQuery サーバサイドの 機能を呼び出し ほぼHTMLで そのまま記述
  • 22. actionSupport コントローラ のメソッドを イベントを 呼び出す 指定 <apex:inputText value="{!recordInputText}"> <apex:actionSupport action="{!refresh}" event="onchange” reRender="parentPanel"> <apex:param assignTo="{!var1}" value="{!recordId}" name="recordParam"/> </apex:actionSupport> </apex:inputText> イベントの発生に合わせて、コントローラのメソッドを呼び出す • JavaScriptを書かずにイベント処理を実現 • 結果はreRenderで
  • 23. actionFunction コントローラの 名前を メソッドを指定 付ける <apex:actionFunction action="{!methodOne}" name="methodOneInJavascript" rerender="showstate"> <apex:param name="firstParam" assignTo="{!state}" value="" 指定した名前で /> </apex:actionFunction> JavaScriptから 呼び出し <script> function clickOne(){ methodOneInJavaScript(); } </script> コントローラのメソッドに名前を付けてJavaScriptから利用できるようにする • 結果はreRenderで
  • 24. JavaScript Remoting コントローラ名.メソッド名で 呼び出し 引数を <script> 渡せる コールバック関数 $(function() { HelloRemote.sayHello('World', function(result, event) { $('#out').text(result); }); }); </script> global class HelloRemote { @RemoteAction global static String sayHello(String name) { リモートアクセス可能な メソッドをアノテーション return 'Hello ' + name + '!'; でマーク } } よりJavaScriptっぽくコントローラのメソッドを呼べる • より柔軟 • ただしコードは増える
  • 25. IDの工夫 <apex:page standardController="Account” recordSetVar="accounts"> <apex:repeat value="{!accounts}" var="account"> <div id=”acct_{!account.id}">{!account.name}</div> </apex:repeat> </apex:page> SFIDをうまく活用 すると一意性を確 <div id=”acct_001A00000090CmoIAE">A商事</div> 保するのが容易 <div id=”acct_001A000000RQgHkIAL”>B商事</div> <div id=”acct_001A000000EaawzIAB">A商事</div> IDは一意で なければいけ ない
  • 26. Javascript + jQuery + Visualforce + Imagination 世界征服をしてやろう!!
  • 27. Mini Page Hover デモ ・レコード名にhoverをしたら、詳細を表示する
  • 28. Mini Page Hover: コード var url = $(this).attr(‘href’) + ‘ div.bDetailBlock’; //hoverしているレコードのURLを取得 $(‘#overlay’).load(url, function () { //#overlayのdivにURLをロードする setTimeout(function () { //overlayを表示する   $(‘#overlay’).show(); }, 200); });
  • 29. Mini Page Hover: コード アドバイス: HTMLで作られているホームページコンポーネントのコードフォーマットが崩れるため、jsbeautifierみたいなツールを使うのがお 勧めです (http://jsbeautifier.org/)
  • 30. デモ iPad アンケート作成用ツール デモ(iPad) セールスフォース側 iPad側
  • 31. iPad アンケート作成用ツール(セールスフォース側) ・jQuery + jQuery UI $( ".answerUL1" ).sortable({ start: function (e, ui) { }, update: function (e, ui) { /*更新時にこのメッソドを行う */ $( “.answerUL .choiceLabel1”).each( function(){ /* 各選択肢のソート番号を更新する */ $(this).find(".choiceSortNumber").val($(this).index()+1); }); /* apexコントローラーを呼び出し、ソート番号を更新する */ sortChoiceList( /*パラメータ省略 */); } }); <apex:actionFunction action="{!sortChoiceList}" reRender="questionPanel" name="sortChoiceList" oncomplete="initSortable();" > /* パラメータ省略 */ </apex:actionFunction>
  • 32. iPad アンケート作成用ツール(セールスフォース側) アドバイス: reRenderの使い方 ページの一部のみ、更新したい場合、 reRenderでapexタグのidを指定すれば、 指定したDOMしか更新されません。 reRenderを使う時に、できるだけ小さいDOMを 設定しないと、重くなる可能性があります。 <apex:actionFunction action="{!sortChoiceList}" reRender="questionPanel" name="sortChoiceList" oncomplete="initSortable();" /> 選択肢の順番を更新したいため、選択肢 を持っているパネルを更新します。全ペー ジを更新したら、重くなりますので、小さい 範囲で更新したほうが良いです。
  • 33. iPad アンケート作成用ツール(iPad側) ・jQuery + jQuery Mobile ・複数のプラットフォームで見えるページを モバイル向けのUIで簡単に作成ができるので、 jQuery Mobileで作りました。 apex:repeatでページ、 質問、選択肢を ループして表示している