Building a Single Page App with Lightning
ComponentsMarch 15, 2017
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 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.
Forward-Looking Statement
Go Social!
@salesforcedevs
Salesforce Developers
Salesforce Developers
Salesforce Developers
This webinar is being recorded!
The video will be posted to YouTube and the
webinar recap page (same URL as
registration).
Have Questions?
• Don’t wait until the end to ask your question!
— Technical support will answer questions starting now.
• 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
Agenda
1. Intro: SendOffer LC
2. Single-Page Application (SPA)
3. Lightning Base Components
4. Lightning Events & CSS
5. Dynamic creation of Lightning Components
6. Demo
7. Resources
SendOffer Lightning Component
1. We built a Recruitment Application that handles
candidates, interviews, and offers.
2. SendOffer LC provides an easy way to construct and send
offer letter to candidate
3. 4 Stages: Detail, Edit, Review, Send
Single Page Application (SPA)
1. Does not require page reloads to work
2. Faster than Page-Centric Apps
3. Usually built with Javascript, CSS, Ajax
4. Examples: Salesforce Lightning Experience, Salesforce 1
Send Offer LC (SPA)
OfferLetterSPA.cmp
Lightning Base Components
1. Built in on the platform
- No more html + SLDS + javascript work
2. Lightning:Input
3. Lightning:Select
4. Lightning:Icon
5. Lightning:TextArea
6. Lightning:button
Lightning Events & CSS
1. Application Events
- passing data between children
2. Component Events & CSS
- bubbling - show and hide children Components
Dynamic Creation of LCs
1. Gives you more flexibility
2. Define which child LCs and which attributes should be
created based on
- data (eg. list row should show as read-only or not)
- user interaction (eg. add error messages
dynamically based on validation checks)
Demo
OfferLetterSPA.cmp (Parent)
OfferDetails.cmpOfferTemplate.cmp
Component Events
Offer_D
etails_N
ext
Offer_T
emplate
_Next
OfferPreview.cmp
Application Events
OfferTemplate
(child 2)
OfferPreview
(child 3)
OfferDetails
(child 1)
OfferConfirm
(child 4)
OrgCandidateDe
tailEvent.evt
——————
—————
• CandidateID
• E-Mail
• Salary
• Bonus
• TemplateID
• OfferId
• OfferLetter
CandidateDe
tailEvent.evt
——————
—————
• CandidateID
• E-Mail
• Salary
• Bonus
• TemplateID
• OfferId
• OfferLetter
Lightning
Framework
Lightning
Framework
CandidateDe
tailEvent.evt
——————
—————
• CandidateID
• E-Mail
• Salary
• Bonus
• TemplateID
• OfferId
• OfferLetter
CandidateDe
tailEvent.evt
——————
—————
• CandidateID
• E-Mail
• Salary
• Bonus
• TemplateID
• OfferId
• OfferLetter
Org
Dynamic Creation of LCs
List.cmpListController.js
<apex:Component>
<div>
{!v.Body}
</div>
</apex:Component>
// JS Controller:
//Loop
for (i = 0; i <
list.length; i++)
{
if (i.isReadOnly){
// Create Row
Component without Edit
Link
}
else
// Create Row
Component with Edit Link
}
Resources
1. Lightning Base Components (Link)
2. Lightning Events (Link)
3. Show/Hide Markup with CSS (Link)
4. Dynamic creation of LCs (Link)
5. Github (Link)
#forcewebinar
Deploying Your Code
Survey
Your feedback is crucial to the success
of our webinar programs. Thank you!
https://sfdc.co/singlepagelightning
Q&A
Try Trailhead: trailhead.salesforce.com
Join the conversation: @salesforcedevs
Thank You

Building a Single Page App with Lightning Components

  • 1.
    Building a SinglePage App with Lightning ComponentsMarch 15, 2017
  • 2.
    Statement under thePrivate 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 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. Forward-Looking Statement
  • 3.
    Go Social! @salesforcedevs Salesforce Developers SalesforceDevelopers Salesforce Developers This webinar is being recorded! The video will be posted to YouTube and the webinar recap page (same URL as registration).
  • 4.
    Have Questions? • Don’twait until the end to ask your question! — Technical support will answer questions starting now. • 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
  • 5.
    Agenda 1. Intro: SendOfferLC 2. Single-Page Application (SPA) 3. Lightning Base Components 4. Lightning Events & CSS 5. Dynamic creation of Lightning Components 6. Demo 7. Resources
  • 6.
    SendOffer Lightning Component 1.We built a Recruitment Application that handles candidates, interviews, and offers. 2. SendOffer LC provides an easy way to construct and send offer letter to candidate 3. 4 Stages: Detail, Edit, Review, Send
  • 7.
    Single Page Application(SPA) 1. Does not require page reloads to work 2. Faster than Page-Centric Apps 3. Usually built with Javascript, CSS, Ajax 4. Examples: Salesforce Lightning Experience, Salesforce 1
  • 8.
    Send Offer LC(SPA) OfferLetterSPA.cmp
  • 9.
    Lightning Base Components 1.Built in on the platform - No more html + SLDS + javascript work 2. Lightning:Input 3. Lightning:Select 4. Lightning:Icon 5. Lightning:TextArea 6. Lightning:button
  • 10.
    Lightning Events &CSS 1. Application Events - passing data between children 2. Component Events & CSS - bubbling - show and hide children Components
  • 11.
    Dynamic Creation ofLCs 1. Gives you more flexibility 2. Define which child LCs and which attributes should be created based on - data (eg. list row should show as read-only or not) - user interaction (eg. add error messages dynamically based on validation checks)
  • 12.
  • 13.
  • 14.
    Application Events OfferTemplate (child 2) OfferPreview (child3) OfferDetails (child 1) OfferConfirm (child 4) OrgCandidateDe tailEvent.evt —————— ————— • CandidateID • E-Mail • Salary • Bonus • TemplateID • OfferId • OfferLetter CandidateDe tailEvent.evt —————— ————— • CandidateID • E-Mail • Salary • Bonus • TemplateID • OfferId • OfferLetter Lightning Framework Lightning Framework CandidateDe tailEvent.evt —————— ————— • CandidateID • E-Mail • Salary • Bonus • TemplateID • OfferId • OfferLetter CandidateDe tailEvent.evt —————— ————— • CandidateID • E-Mail • Salary • Bonus • TemplateID • OfferId • OfferLetter Org
  • 15.
    Dynamic Creation ofLCs List.cmpListController.js <apex:Component> <div> {!v.Body} </div> </apex:Component> // JS Controller: //Loop for (i = 0; i < list.length; i++) { if (i.isReadOnly){ // Create Row Component without Edit Link } else // Create Row Component with Edit Link }
  • 16.
    Resources 1. Lightning BaseComponents (Link) 2. Lightning Events (Link) 3. Show/Hide Markup with CSS (Link) 4. Dynamic creation of LCs (Link) 5. Github (Link)
  • 17.
  • 18.
    Survey Your feedback iscrucial to the success of our webinar programs. Thank you! https://sfdc.co/singlepagelightning
  • 19.
    Q&A Try Trailhead: trailhead.salesforce.com Jointhe conversation: @salesforcedevs
  • 20.

Editor's Notes

  • #8 So what is a Single-Page-Application or SPA? It is basically an app that works inside a browser and does not require the user to reload the page for the app to work. SPAs try to imitate a “natural” environment in the browser – no page reloads, no extra wait time - and to keep the user in one, comfortable web space where content is presented in a simple, easy and workable fashion. A good example of a SPA is the Salesforce Lightning Experience UI itself. Our goal for today's demo is to demonstrate how you can create a mini SPA inside a Lightning Component as this type of design is highly interactive and can open up interesting possibilities for your app's UI.
  • #9 You can see on this diagram, we have a parent Lightning Component called OfferLetterSPA that acts as our SPA outermost Container which means it will be always visible and that's the LC that our users will drag and drop to Lightning Pages using the Lightning App Builder. Inside this parent Lightning container we are going to surface up different child Lightning Components and we are going to control their visibility from this Parent LC whenever the user clicks on the Next or Back buttons on the child components