JavaScript Integration with Visualforce
Description
Visualforce has come a long way when with its ability to integrate with JavaScript. Developers are no longer limited to simply looping Apex functions via the actionFunction component, with Remote Objects live in the last Summer release it is possible to create fully functional HTML5 applications without writing any Apex for basic cread, read, update, delete and query functions.
Join Developer Evangelist Josh Birk as he walks through the various aspects of Visualforce which makes it easy to build applications in a variety of HTML5 frameworks and libraries.
Key Takeaways
::Visualforce now supports a fine level of control over how the page is constructed
::With JavaScript Remoting and Remote Objects you can easily integrate the data layer into your application
::Integrating existing HTML5 frameworks and libraries is easy with Visualforce
Intended Audience
::Existing Visualforce developers looking to keep up to date on the latest features when using JavaScript.
::HTML5 Developers interested in leverage Visualforce to build their applications.
Recommended Resources:
https://developer.salesforce.com/en/events/webinars/JavaScript_Integration_with_Visualforce
3. 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.
#forcewebinar
4. Go Social!
@salesforcedevs / #forcewebinar
Salesforce Developers
Salesforce Developers
Salesforce Developers
+Salesforce Developers
#forcewebinar
This webinar is being recorded!
The video will be posted to YouTube
& the webinar recap page
(same URL as registration).
5. Have Questions?
▪ Don’t wait until the end to ask your question!
– Technical support will answer questions starting now.
▪ Respect Q&A etiquette
– Please don’t repeat questions. The support team is
#forcewebinar
working their way down the queue.
▪ Stick around for live Q&A at the end
– Speakers will tackle more questions at the end, time-allowing.
▪ Head to Developer Forums
– More questions? Visit developer.salesforce.com/forums
6. Agenda
1. Making Visualforce JavaScript friendly
2. Leveraging JavaScript Remoting with Visualforce
3. Using Remote Objects with Angular.js
#forcewebinar
7. Setting up Visualforce for HTML5
Set the DOCTYPE
<apex:page
#forcewebinar
standardStylesheets="false"
showheader="false"
sidebar="false"
applyHtmlTag="false"
applyBodyTag="false"
docType="html-5.0"
>
8. Setting up Visualforce for HTML5
Control the HTML and BODY tags
<apex:page
#forcewebinar
standardStylesheets="false"
showheader="false"
sidebar="false"
applyHtmlTag="false"
applyBodyTag="false"
docType="html-5.0"
>
9. Setting up Visualforce for HTML5
Using HTML Pass-throughs
<apex:outputPanel layout="block" html-data-role="panel" html-data-id="
menu">
<apex:insert name="menu"/>
</apex:outputPanel>
#forcewebinar
<div data-id="menu" data-role="panel">
<!-- contents of menu -->
</div>
12. Integrate JavaScript directly with Apex
Using JavaScript Remoting
@RemoteAction
global static Contact makeContact
Visualforce.remoting.Manager.invokeAction(
#forcewebinar
'{!$RemoteAction.ContactExtension.makeContact}',
“003i000000cxdHP”, “Barr”
function(result, event) {
//...callback to handle result
alert(result.LastName);
});
(String cid, String lname) {
return new Contact(id=cid,Last_Name=lname);
}
Visualforce Apex
13. JavaScript Remoting Advantages
1. No viewstate, performs better with larger data sets
2. Direct integration with existing JavaScript
3. No use of the API scope
#forcewebinar
14. Remote Objects for integrating directly with data
<apex:remoteObjects >
<apex:remoteObjectModel name="Contact" jsShorthand="contact"
#forcewebinar
fields="FirstName,LastName,Id,Email"/>
contacts.retrieve({},function(error, records) {
if(error) { console.log(error.message); }
else {
data = records;
});
15. Remote Objects Advantages
1. Same advantages of JavaScript Remoting
2. No Apex Required
3. Can reference multiple data models
4. Can replace specific functions with JavaScript Remoting
#forcewebinar