Coding Apps in the Cloud with Force.com - Part 2
-
Upload
salesforce-developers -
Category
Technology
-
view
828 -
download
5
Transcript of Coding Apps in the Cloud with Force.com - Part 2
![Page 1: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/1.jpg)
#forcewebinar
Coding Apps in the Cloud with Force.com – Part IIMarch 31st , 2016
![Page 2: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/2.jpg)
#forcewebinar#forcewebinar
Speakers
Shashank SrivatsavayaSr. Developer Advocate Engineer@shashforce
Sonam RajuSr. Developer Advocate Engineer@sonamraju14
![Page 3: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/3.jpg)
Forward Looking Statement
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 any litigation, risks associated with completed and any 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-K for the most recent fiscal year and in our quarterly report on Form 10-Q for the most recent fiscal quarter. These 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.
Statement under the Private Securities Litigation Reform Act of 1995:
![Page 4: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/4.jpg)
#forcewebinar
Go Social!@salesforcedevs / #forcewebinar
Salesforce Developers
Salesforce Developers
Salesforce Developers
This webinar is being recorded!The video will be posted toYouTube & the webinar recappage (same URL as registration).
![Page 5: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/5.jpg)
#forcewebinar
Agenda• Part I – Demo• Visualforce Pages• Controllers• Javascript in Visualforce Pages• Part II - Demo• Q&A
![Page 6: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/6.jpg)
#forcewebinar
Part I : Demo(Data Model, Application, Apex, SOQL, Triggers)
![Page 7: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/7.jpg)
#forcewebinar
Visualforce
![Page 8: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/8.jpg)
#forcewebinar
What's a Visualforce Page?
▪HTML page with tags executed at the server-side to generate dynamic content▪Similar to JSP and ASP▪Can leverage JavaScript and CSS libraries▪The View in MVC architecture
![Page 9: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/9.jpg)
#forcewebinar
Model-View-Controller
ModelData + Rules
ControllerView-Modelinteractions
ViewUI code
▪Separation of concerns– No data access code in view– No view code in controller
▪Benefits– Minimize impact of changes– More reusable components
![Page 10: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/10.jpg)
#forcewebinar
Model-View-Controller in SalesforceView
• Standard Pages• Visualforce Pages• External apps
Controller• Standard
Controllers• Controller
Extensions• Custom
Controllers
Model• Objects• Triggers (Apex)• Classes (Apex)
![Page 11: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/11.jpg)
#forcewebinar
Component Library▪Presentation tags
– <apex:pageBlock title="My Account Contacts">▪Fine grained data tags
– <apex:outputField value="{!contact.firstname}">– <apex:inputField value="{!contact.firstname}">
▪Coarse grained data tags– <apex:detail>– <apex:pageBlockTable>
▪Action tags– <apex:commandButton action="{!save}" >
![Page 12: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/12.jpg)
#forcewebinar
Expression Language
▪Anything inside of {! } is evaluated as an expression▪Same expression language as Formulas▪$ provides access to global variables (User,
RemoteAction, Resource, …)– {! $User.FirstName } {! $User.LastName }
![Page 13: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/13.jpg)
#forcewebinar
Example 1• <apex:page>• <h1>Hello, {!$User.FirstName}</h1>• </apex:page>
![Page 14: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/14.jpg)
#forcewebinar
Controllers
![Page 15: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/15.jpg)
#forcewebinar
Standard Controller
▪A standard controller is available for all objects– You don't have to write it!
▪Provides standard CRUD operations– Create, Update, Delete, Field Access, etc.
▪Can be extended with more capabilities▪Uses id query string parameter in URL to access
object
![Page 16: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/16.jpg)
#forcewebinar
Example 2• <apex:page standardController="Contact">• <apex:form>• <apex:inputField value="{!contact.firstname}"/>• <apex:inputField value="{!contact.lastname}"/>• <apex:commandButton action="{!save}" value="Save"/>• </apex:form>• </apex:page>
Function in standard controller
Standard controller
object
![Page 17: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/17.jpg)
#forcewebinar
Email Templates
Embedded in Page Layouts
Generate PDFs
Custom Tabs
Mobile Interfaces
Page Overrides
Where can I use Visualforce?
![Page 18: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/18.jpg)
#forcewebinar
What's a Custom Controller?• Custom class written in Apex• Doesn't work on a specific object• Provides custom data• Provides custom behaviors
![Page 19: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/19.jpg)
#forcewebinar
Defining a Custom Controller
<apex:page controller="FlickrController">
![Page 20: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/20.jpg)
#forcewebinar
Custom Controller Examplepublic with sharing class FlickrController { public FlickrList getPictures() { HttpRequest req = new HttpRequest(); req.setMethod('GET'); req.setEndpoint('http://api.flickr.com/services/feeds/'); HTTP http = new HTTP(); HTTPResponse res = http.send(req); return (FlickrList) JSON.deserialize(res.getBody(), FlickrList.class); }}
![Page 21: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/21.jpg)
#forcewebinar
What's a Controller Extension?• Custom class written in Apex• Works on the same object as the standard controller• Can override standard controller behavior• Can add new capabilities
![Page 22: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/22.jpg)
#forcewebinar
Defining a Controller Extension
<apex:page standardController="Speaker__c" extensions="SpeakerCtrlExt">
Provides basic CRUD
Overrides standard actions and/or provide additional capabilities
![Page 23: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/23.jpg)
#forcewebinar
Defining a Controller Extension
<apex:page standardController="Speaker__c" extensions="CtrlExt1,CtrlExt2,CtrlExt3">
Provides basic CRUD
Can contain multiple extensions
![Page 24: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/24.jpg)
#forcewebinar
Anatomy of a Controller Extensionpublic class SpeakerCtrlExt {
private final Speaker__c speaker; private ApexPages.StandardController stdController;
public SpeakerCtrlExt (ApexPages.StandardController ctrl) { this.stdController = ctrl; this.speaker = (Speaker__c)ctrl.getRecord(); } // method overrides // custom methods}
![Page 25: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/25.jpg)
#forcewebinar
Javascript in Visualforce Pages
![Page 26: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/26.jpg)
#forcewebinar
Why Use JavaScript?• Build Engaging User Experiences• Leverage JavaScript Libraries• Build Custom Applications
![Page 27: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/27.jpg)
#forcewebinar
JavaScript in Visualforce Pages
Visualforce Page
JavaScript RemotingRemote Objects
(REST)
![Page 28: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/28.jpg)
#forcewebinar
Examples
![Page 29: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/29.jpg)
#forcewebinar
JavaScript Remoting - Server-Sideglobal with sharing class HotelRemoter {
@RemoteAction global static List<Hotel__c> findAll() { return [SELECT Id,
Name, Location__Latitude__s, Location__Longitude__s
FROM Hotel__c]; }
}
![Page 30: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/30.jpg)
#forcewebinar
"global with sharing"?• global
• Available from outside of the application• with sharing
• Run code with current user permissions. (Apex code runs in system context by default -- with access to all objects and fields)
![Page 31: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/31.jpg)
#forcewebinar
JavaScript Remoting - Visualforce Page
<script>Visualforce.remoting.Manager.invokeAction( '{!$RemoteAction.HotelRemoter.findAll}', function (result, event) { if (event.status) { for (var i = 0; i < result.length; i++) {
var lat = result[i].Location__Latitude__s; var lng = result[i].Location__Longitude__s; addMarker(lat, lng); } } else { alert(event.message); } });</script>
![Page 32: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/32.jpg)
#forcewebinar
Using JavaScript and CSS Libraries
• Hosted elsewhere<script src="https://maps.googleapis.com/maps/api/js"></script>
• Hosted in Salesforce• Upload individual file or Zip file as Static Resource• Reference asset using special tags
![Page 33: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/33.jpg)
#forcewebinar
Static Resources
![Page 34: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/34.jpg)
#forcewebinar
Referencing Static Resources// Single file<apex:stylesheet value="{!$Resource.bootstrap}"/><apex:includeScript value="{!$Resource.jquery}"/><apex:image url="{!$Resource.logo}"/>
// ZIP file<apex:stylesheet value="{!URLFOR($Resource.assets, 'css/main.css')}"/><apex:image url="{!URLFOR($Resource.assets, 'img/logo.png')}"/><apex:includeScript value="{!URLFOR($Resource.assets, 'js/app.js')}"/>
![Page 35: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/35.jpg)
#forcewebinar
Referencing Static Resources// Single file<link href="{!$Resource.bootstrap}" rel="stylesheet"/><img src="{!$Resource.logo}"/><script src="{!$Resource.jquery}"></script>
// ZIP file<link href="{!URLFOR($Resource.assets, 'css/main.css')}" rel="stylesheet"/><img src="{!URLFOR($Resource.assets, 'img/logo.png')}"/><script src="{!URLFOR($Resource.assets, 'js/app.js')}"></script>
![Page 36: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/36.jpg)
#forcewebinar
Demo(Visualforce with Standard controller and Extension,
Custom Controller and Javascript)
![Page 37: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/37.jpg)
developer.salesforce.com/trailhead
![Page 38: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/38.jpg)
#forcewebinar#forcewebinar
Recommended Trail:
![Page 39: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/39.jpg)
#forcewebinar#forcewebinar
Got Questions?
Post’em tohttp://developer.salesforce.com/forums/
![Page 40: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/40.jpg)
#forcewebinar#forcewebinar
Q&A
Your feedback is crucial to the successof our webinar programs. Thank you!
http://bit.ly/forcewebinarfeedback
![Page 41: Coding Apps in the Cloud with Force.com - Part 2](https://reader034.fdocuments.us/reader034/viewer/2022042604/58a4557f1a28ab55068b5ea3/html5/thumbnails/41.jpg)
#forcewebinar#forcewebinar
Thank You Try Trailhead: trailhead.salesforce.com
Join the conversation: #forcewebinar@salesforcedevs @SonamRaju14 @shashforce