View
347
Download
1
Category
Preview:
DESCRIPTION
A round up of the state of Javascript on Force.com now that remote objects are about to go GA on Force.com in Winter 15. There are now four great options for invoking Javascript on your Visualforce page. Learn what they are, and more importantly why you need all of them, and when to use each one. Delivered at Salesforce Developer Group North on 18 September, 2014.
Citation preview
A Miscellany of Things Force.com
Peter Chittum@pchittumgithub.com/pchittumslideshare.com/chittum
Safe HarborSafe 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 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, 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, 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-K for the most recent fiscal quarter ended July 31, 2011. This document and others 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 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.
What’s On?
Javascript on Visualforce
Remote Objects
RevealJS
JS Options for Visualforce
Tag: apex:actionFunction
API Calls
@RemoteAction Apex Methods
Remote Object
The Old Way
actionFunction Pros– Easy and Declarative
API Pros– Use of idiomatic JS
– No ViewState Overhead
– Higher data size limits
– Simple REST access via ForceTK
actionFunction Cons– ViewState and VF
Postback overhead
API Cons– Burning API limit usage
The Newer Way
@RemoteAction Apex Method– Stateless
– More idiomatic (uses callback)
– Simplified on client side with RemoteTK library
The New Way
Remote Object– Like Standard Controller and Remote methods got
together and had a baby
– Declared via markup
– No Apex, no required tests, just Javascript code
– Support for basic CRUD operations
The Three Musketeers
Remote Object– First choice for basic CRUD
@RemoteAction Apex Method– Move complexity to server and transaction control
API– Larger data (binary files)
What’s On?
Javascript on Visualforce
Remote Objects
RevealJS
More on Remote Object
GA in Winter 15!
CRUD: Create, Retrieve, Update, Upsert, Delete
Optional page-specific JS namespace
Maps long Salesforce field names to JS-friendly names
Remote Object: Declaration
<apex:remoteObjects >
<apex:remoteObjectModel name="pcprerel__Damage_Report__c”
fields="Id,Name" jsShorthand="DamageReport">
<apex:remoteObjectField name="pcprerel__Merchandise__c"
jsShorthand="merchId"/>
<apex:remoteObjectField name="pcprerel__Type__c"
jsShorthand="type"/>
...
</apex:remoteObjectModel>
</apex:remoteObjects>
Remote Object: Create JS Object
var dr = new SObjectModel.DamageReport({
"merchId" : "{!Merchandise__c.Id}",
"type" : "Accident",
"description" : $('#ta-description').val()
});
Remote Object: Invoke DML
dr.create(function(err, result, event){
//debug with event to find out transaction status
if (err) {
console.log(err);
//do stuff with err
} else {
//use result
$('#test-display').text('Damage Report Id: '+result[0] );
}
});
Demo
Other Features
Overriding of CRUD calls
Own set of limits (i.e. max 100 rows for retrieve)
Use rendered VF attribute to block generation of JS
What’s On?
Javascript on Visualforce
Remote Objects
RevealJS
RevealJS
Javascript library
Creating pure HTML presentations
Opensource at https://github.com/hakimel/reveal.js/
Cloud hosted at http://slid.es
Demo
Watch this play list to see RevealJS on Force.comhttp://www.youtube.com/playlist?list=PLkZK3G49sP2xE-yzEMvVJhbHmGMMDOkLz
Thank You
Recommended