SlideShare a Scribd company logo
Building Lightning Components
Christophe Coenraets
Developer Evangelist
#TrailheadLive
@ccoenraets
http://developer.salesforce.com/trailhead/projects
What you will do
Build an Account Locator built as a a set
of loosely coupled components
communicating through events
Explore different deployment options:
• Lightning App
• Salesforce1 App
• App Builder Composition
AccountMap
AccountList
AccountLocator
AccountListItem
Step 1:
Setting Up Your Environment
1. Sign up for a Developer Edition Org
2. Enable My Domain
3. Deploy to Users
Challenge
Step 2:
Enabling Geolocation on Accounts
1. Add a geolocation field to the Account object
2. Enter sample data
Challenge
Step 3:
Creating an Aura-Enabled Controller
Visualforce Page-Centric Model
1. Browser requests page
Client Server
4. Browser renders html
2. Server executes Apex code
3. Server returns page (html + data)
Show different data? Back to 1
Show different view? Back to 1
Pros
1. Proven model
2. Productivity. Easy to implement
3. Naturally splits large apps into small, manageable units (pages)
Caveats
1. Limited interactivity
2. Higher latency
Visualforce Page Centric Model
Lightning App-Centric Model
1. Browser requests Component
Client Server
3. Browser builds UI with JavaScript
4. Browser requests data
7. Back to 3
2. Server returns Component Bundle
5. Server executes Apex
6. Server returns data (data only!)
Show different data? Back to 4
Show different view? Back to 3
Pros
• Enables highly interactive/immersive user experiences
• Less page refreshes
• Tightly integrated (no iframe)
• Composable
Caveats
• Higher learning curve compared to vanilla Visualforce pages
• Higher level of complexity. Building an app is generally more complex than building a page
Lightning Components App Centric Model
Creating an Aura-Enabled Apex Controller
public with sharing class AccountController {
@AuraEnabled
public static List<Account> findAll() {
return [SELECT id, name FROM Account];
}
}
* You should add code to enforce CRUD and FLS
1. Create an Aura-enabled Apex controller named
AccountController
2. Add a findAll() method that returns accounts that have location
information
Challenge
Step 4:
Creating the AccountLocator Component
Anatomy of a Lightning Component
<aura:component controller="AccountController">
<div>
<div>AccountMap goes here</div>
<div>AccountList goes here</div>
</div>
</aura:component>
Component Parts: Component
UI Markup
Data binding
Attributes
Component
Component Parts: Style
UI Markup
Data binding
Attributes
ComponentStyle
Encapsulated
CSS
1. In Lightning Applications
2. In the Salesforce1 app
3. In App Builder
Where can I use Lightning Components?
Using a Lightning Component in a Lightning App
1. Create a Lightning App
File > New > Lightning Application
2. Embed the Lightning Component
<aura:application>
<c:AccountLocator/>
</aura:application>
Useful for creating fullscreen apps or for testing components during development
Using a Lightning Component in the Salesforce1 App
1. Implement the force:appHostable interface
<aura:component implements="force:appHostable">
2. Create a Tab
3. Add the Tab to Mobile Navigation
1. Create the AccountLocator component
2. Add AccountLocator to the Salesforce1 App menu
Challenge
Step 5:
Creating the AccountList Component
Attributes
• The data of the component
• Available anywhere in the component
• Examples:
<aura:attribute name="price" type="Number"/>
<aura:attribute name="title" type="String"/>
<aura:attribute name="account" type="Account"/>
<aura:attribute name="accounts" type="Account[]"/>
Data Binding {! }
<aura:attribute name="account" type="Account"/>
<p>{!v.account.Name}</p>
 Initial value of <p> is set to the value of account.Name
 Value of <p> automatically updated when value of account.Name changes
Bidirectional Data Binding
<aura:attribute name="price" value="100" type="Number"/>
<ui:inputNumber label="Principal:" value="{!v.price}"/>
 Initial value of inputNumber is set to value of attribute (100)
 Value of price attribute is updated when user types new value in inputNumber
Component Parts: Controller
UI Markup
Data binding
Attributes
Component
Event
Handlers
ControllerStyle
Encapsulated
CSS
<aura:attribute name="counter" type="Number" default="0"/>
<ui:button label="Click me" press="{!c.handleClick}"/>
<div>{!v.counter}</div>
handleClick: function(component, event) {
var counter = component.get("v.counter");
counter = counter + 1;
component.set("v.counter", counter);
}
ComponentControllerEvent Handler Example
Counter
Event Handler Example
Retrieving Data on Init
<aura:attribute name="accounts" type="Accounts[]"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
doInit : function(component, event) {
var action = component.get("c.findAll");
action.setCallback(this, function(a) {
component.set("v.accounts", a.getReturnValue());
});
$A.enqueueAction(action);
}
ComponentController
Iterating through a List
<aura:attribute name="accounts" type="Account[]"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<ul>
<aura:iteration items="{!v.accounts}" var="account">
<li>{!account.Name}</li>
</aura:iteration>
</ul>
Nested Component
• A component used in another component
• AccountListItem Example:
<aura:component>
<aura:attribute name="account" type="Account"/>
<li>{!v.account.Name}</li>
</aura:component>
Using a Nested Component
<aura:attribute name="accounts" type="Account[]"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<ul>
<aura:iteration items="{!v.accounts}" var="account">
<c:AccountListItem account="{!account}"/>
</aura:iteration>
</ul>
1. Create the AccountList component responsible for displaying
the list of accounts
2. Create the AccountListItem component that you nest inside
AccountList to render individual accounts in the list
Challenge
Step 6:
Creating the AccountMap Component
• External JavaScript libraries and CSS style sheets must be loaded as static
resources
• Use the <ltng:require> tag to load them
• Loading is asynchronous
• afterScriptLoaded event is triggered after files have been succesfully loaded
Loading External JavaScript Libraries and CSS Files
Loading External JavaScript Libraries
<ltng:require scripts="/resource/leaflet/leaflet.js"/>
Loading External CSS Style Sheets
<ltng:require styles="/resource/leaflet/leaflet.css" />
Loading JavaScript Libraries and CSS Style Sheets
<ltng:require scripts="/resource/leaflet/leaflet.js"
styles="/resource/leaflet/leaflet.css" />
Using the afterScriptLoaded Event
<ltng:require scripts="/resource/leaflet/leaflet.js"
styles="/resource/leaflet/leaflet.css"
afterScriptsLoaded="{!c.renderMap}" />
1. Load leaflet JS library
2. Load Leaflet CSS
3. Render the map when files are loaded
Challenge
Step 7:
Intercomponent Communication
Intercomponent Communication
Application Event Broker
Event Object
<aura:handler event="c:AccountsLoaded"
action="{!c.accountsLoadedHandler}"/>
<aura:registerEvent name="loaded"
type="c:AccountsLoaded"/>
var event = $A.get("e.c:AccountsLoaded");
event.setParams({"accounts": accounts});
event.fire();
AccountMapAccountList
Creating the AccountsLoaded Event
<aura:event type="APPLICATION">
<aura:attribute name="accounts" Type="Account[]"/>
</aura:event>
1. Create the AccountsLoaded Event
2. Trigger the AccountsLoaded Event in AccountList
3. Handle the AccountsLoaded Event in AccountMap
Challenge
Step 8:
Using Events to Center the Map
Intercomponent Communication
Application Event Broker
Event Object
<aura:handler event="c:AccountSelected"
action="{!c.accountSelectedHandler}"/>
<aura:registerEvent name="select"
type="c:AccountSelected"/>
var event = $A.get("e.c:AccountSelected");
event.setParams({"account": account});
event.fire();
AccountMapAccountList
1. Create the AccountSelected event
2. Trigger the AccountSelected event in AccountList
3. Handle the AccountSelected event in AccountMap and center the map on the
selected account location
Challenge
Step 9:
Interacting with the Salesforce1 App
1. Lightning Components enable you to extend standard features
2. Don't reinvent the wheel
For example, if your component needs an account details view: use the standard one, don't create
your own
3. Navigation between standard features and custom components should be smooth and feel
integrated: users shouldn't notice they are switching between standard and custom features
4. Platform events allow you to integrate your custom components into the standard experience
Salesforce1 Integration
Firing a Platform Event
var event = $A.get("e.force:navigateToSObject");
event.setParams({
"recordId": accountId
});
event.fire();
This event will be handled be the Salesforce1 app which will then navigate to
the account's details view
Component Parts: Helper
UI Markup
Data binding
Attributes
Component
Event
Handlers
Controller
Shared
Logic
HelperStyle
Encapsulated
CSS
When a user clicks a marker on the map, load the default
Salesforce1 details view for the selected account
Challenge
Step 10:
Using Components in App Builder
Using a Lightning Component in App Builder
1. Implement the flexipage:availableForAllPageTypes interface
<aura:component implements="flexipage:availableForAllPageTypes">
2. Create a component description in the Design part
<design:component label="AccountList">
</design:component>
3. Enable App Builder for Lightning Experience (PILOT)
4. Drag the component from the component palette in App Builder
Compose AccountList and AccountMap in App Builder
Challenge
Summary
UI Markup
Data binding
Attributes
Component
Design Descriptor
Event
Handlers
Controller
Shared
Logic
HelperStyle
Custom Rendering
Renderer
Encapsulated
CSS
App Builder
Lightning Components Workshop v2

More Related Content

What's hot

Salesforce World Tour 2016 : Lightning Out : Components on any Platform
Salesforce World Tour 2016 : Lightning Out : Components on any PlatformSalesforce World Tour 2016 : Lightning Out : Components on any Platform
Salesforce World Tour 2016 : Lightning Out : Components on any Platform
andyinthecloud
 
Journey from classic Salesforce development to lightning Developmemt
Journey from classic Salesforce development to lightning DevelopmemtJourney from classic Salesforce development to lightning Developmemt
Journey from classic Salesforce development to lightning Developmemt
Sunil kumar
 
ASP.Net Presentation Part1
ASP.Net Presentation Part1ASP.Net Presentation Part1
ASP.Net Presentation Part1Neeraj Mathur
 
12 asp.net session17
12 asp.net session1712 asp.net session17
12 asp.net session17
Vivek chan
 
Salesforce Lightning Events - Hands on Training
Salesforce Lightning Events - Hands on TrainingSalesforce Lightning Events - Hands on Training
Salesforce Lightning Events - Hands on Training
Sunil kumar
 
Practical Headless Flow Examples
Practical Headless Flow ExamplesPractical Headless Flow Examples
Practical Headless Flow Examples
Salesforce Admins
 
Creating azure logic app for salesforce integration | Webner
Creating azure logic app for salesforce integration | WebnerCreating azure logic app for salesforce integration | Webner
Creating azure logic app for salesforce integration | Webner
ChandanWebner
 
03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04
Vivek chan
 
Salesforce Lightning Data Services- Hands on Training
Salesforce Lightning Data Services- Hands on TrainingSalesforce Lightning Data Services- Hands on Training
Salesforce Lightning Data Services- Hands on Training
Sunil kumar
 
Rits Brown Bag - TypeScript
Rits Brown Bag - TypeScriptRits Brown Bag - TypeScript
Rits Brown Bag - TypeScript
Right IT Services
 
Apex Enterprise Patterns: Building Strong Foundations
Apex Enterprise Patterns: Building Strong FoundationsApex Enterprise Patterns: Building Strong Foundations
Apex Enterprise Patterns: Building Strong Foundations
Salesforce Developers
 
An IT Pro Guide to Deploying and Managing SharePoint 2013 Apps
An IT Pro Guide to Deploying and Managing SharePoint 2013 AppsAn IT Pro Guide to Deploying and Managing SharePoint 2013 Apps
An IT Pro Guide to Deploying and Managing SharePoint 2013 Apps
Randy Williams
 
SharePoint Hosted Add-in with AngularJS and Bootstrap
SharePoint Hosted Add-in with AngularJS and BootstrapSharePoint Hosted Add-in with AngularJS and Bootstrap
SharePoint Hosted Add-in with AngularJS and Bootstrap
Roy Kim
 
Introduction Asp.Net Core, MVC, Docker (Linux), Postman and Swagger
Introduction Asp.Net Core, MVC, Docker (Linux), Postman and SwaggerIntroduction Asp.Net Core, MVC, Docker (Linux), Postman and Swagger
Introduction Asp.Net Core, MVC, Docker (Linux), Postman and Swagger
Agusto Sipahutar
 
Flow in Salesforce
Flow in SalesforceFlow in Salesforce
Flow in Salesforce
vikas singh
 
Atlanta user group presentation configero 8 nov11
Atlanta user group presentation configero 8 nov11Atlanta user group presentation configero 8 nov11
Atlanta user group presentation configero 8 nov11vraopolisetti
 
CCI 2019 - PowerApps for Enterprise Developers
CCI 2019 - PowerApps for Enterprise DevelopersCCI 2019 - PowerApps for Enterprise Developers
CCI 2019 - PowerApps for Enterprise Developers
walk2talk srl
 
Building strong foundations apex enterprise patterns
Building strong foundations apex enterprise patternsBuilding strong foundations apex enterprise patterns
Building strong foundations apex enterprise patterns
andyinthecloud
 
Integrating ASP.NET AJAX with SharePoint
Integrating ASP.NET AJAX with SharePointIntegrating ASP.NET AJAX with SharePoint
Integrating ASP.NET AJAX with SharePoint
Rob Windsor
 

What's hot (19)

Salesforce World Tour 2016 : Lightning Out : Components on any Platform
Salesforce World Tour 2016 : Lightning Out : Components on any PlatformSalesforce World Tour 2016 : Lightning Out : Components on any Platform
Salesforce World Tour 2016 : Lightning Out : Components on any Platform
 
Journey from classic Salesforce development to lightning Developmemt
Journey from classic Salesforce development to lightning DevelopmemtJourney from classic Salesforce development to lightning Developmemt
Journey from classic Salesforce development to lightning Developmemt
 
ASP.Net Presentation Part1
ASP.Net Presentation Part1ASP.Net Presentation Part1
ASP.Net Presentation Part1
 
12 asp.net session17
12 asp.net session1712 asp.net session17
12 asp.net session17
 
Salesforce Lightning Events - Hands on Training
Salesforce Lightning Events - Hands on TrainingSalesforce Lightning Events - Hands on Training
Salesforce Lightning Events - Hands on Training
 
Practical Headless Flow Examples
Practical Headless Flow ExamplesPractical Headless Flow Examples
Practical Headless Flow Examples
 
Creating azure logic app for salesforce integration | Webner
Creating azure logic app for salesforce integration | WebnerCreating azure logic app for salesforce integration | Webner
Creating azure logic app for salesforce integration | Webner
 
03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04
 
Salesforce Lightning Data Services- Hands on Training
Salesforce Lightning Data Services- Hands on TrainingSalesforce Lightning Data Services- Hands on Training
Salesforce Lightning Data Services- Hands on Training
 
Rits Brown Bag - TypeScript
Rits Brown Bag - TypeScriptRits Brown Bag - TypeScript
Rits Brown Bag - TypeScript
 
Apex Enterprise Patterns: Building Strong Foundations
Apex Enterprise Patterns: Building Strong FoundationsApex Enterprise Patterns: Building Strong Foundations
Apex Enterprise Patterns: Building Strong Foundations
 
An IT Pro Guide to Deploying and Managing SharePoint 2013 Apps
An IT Pro Guide to Deploying and Managing SharePoint 2013 AppsAn IT Pro Guide to Deploying and Managing SharePoint 2013 Apps
An IT Pro Guide to Deploying and Managing SharePoint 2013 Apps
 
SharePoint Hosted Add-in with AngularJS and Bootstrap
SharePoint Hosted Add-in with AngularJS and BootstrapSharePoint Hosted Add-in with AngularJS and Bootstrap
SharePoint Hosted Add-in with AngularJS and Bootstrap
 
Introduction Asp.Net Core, MVC, Docker (Linux), Postman and Swagger
Introduction Asp.Net Core, MVC, Docker (Linux), Postman and SwaggerIntroduction Asp.Net Core, MVC, Docker (Linux), Postman and Swagger
Introduction Asp.Net Core, MVC, Docker (Linux), Postman and Swagger
 
Flow in Salesforce
Flow in SalesforceFlow in Salesforce
Flow in Salesforce
 
Atlanta user group presentation configero 8 nov11
Atlanta user group presentation configero 8 nov11Atlanta user group presentation configero 8 nov11
Atlanta user group presentation configero 8 nov11
 
CCI 2019 - PowerApps for Enterprise Developers
CCI 2019 - PowerApps for Enterprise DevelopersCCI 2019 - PowerApps for Enterprise Developers
CCI 2019 - PowerApps for Enterprise Developers
 
Building strong foundations apex enterprise patterns
Building strong foundations apex enterprise patternsBuilding strong foundations apex enterprise patterns
Building strong foundations apex enterprise patterns
 
Integrating ASP.NET AJAX with SharePoint
Integrating ASP.NET AJAX with SharePointIntegrating ASP.NET AJAX with SharePoint
Integrating ASP.NET AJAX with SharePoint
 

Viewers also liked

Lighnting component development
Lighnting component developmentLighnting component development
Lighnting component development
Mohith Shrivastava
 
Lightning componentとlightning design system
Lightning componentとlightning design systemLightning componentとlightning design system
Lightning componentとlightning design system
Noriko Iwai
 
Lightning Component × Lightning Design System
Lightning Component × Lightning Design SystemLightning Component × Lightning Design System
Lightning Component × Lightning Design System
Taiki Yoshikawa
 
Workbook for Lightning Developers
Workbook for Lightning DevelopersWorkbook for Lightning Developers
Workbook for Lightning Developers
Right IT Services
 
September SDG - Lightning
September SDG - LightningSeptember SDG - Lightning
September SDG - Lightning
Josep Vall-llovera
 
February'16 SDG - Spring'16 new features
February'16 SDG - Spring'16 new featuresFebruary'16 SDG - Spring'16 new features
February'16 SDG - Spring'16 new features
Josep Vall-llovera
 
Lightning Components Introduction
Lightning Components IntroductionLightning Components Introduction
Lightning Components Introduction
Durgesh Dhoot
 
Salesforce Lightning workshop
Salesforce Lightning workshopSalesforce Lightning workshop
Salesforce Lightning workshop
Shivanath Devinarayanan
 
Lightning Chess, The fun way to learn the Lightning Component Framework
Lightning Chess, The fun way to learn the Lightning Component FrameworkLightning Chess, The fun way to learn the Lightning Component Framework
Lightning Chess, The fun way to learn the Lightning Component Framework
Lieven Juwet
 

Viewers also liked (9)

Lighnting component development
Lighnting component developmentLighnting component development
Lighnting component development
 
Lightning componentとlightning design system
Lightning componentとlightning design systemLightning componentとlightning design system
Lightning componentとlightning design system
 
Lightning Component × Lightning Design System
Lightning Component × Lightning Design SystemLightning Component × Lightning Design System
Lightning Component × Lightning Design System
 
Workbook for Lightning Developers
Workbook for Lightning DevelopersWorkbook for Lightning Developers
Workbook for Lightning Developers
 
September SDG - Lightning
September SDG - LightningSeptember SDG - Lightning
September SDG - Lightning
 
February'16 SDG - Spring'16 new features
February'16 SDG - Spring'16 new featuresFebruary'16 SDG - Spring'16 new features
February'16 SDG - Spring'16 new features
 
Lightning Components Introduction
Lightning Components IntroductionLightning Components Introduction
Lightning Components Introduction
 
Salesforce Lightning workshop
Salesforce Lightning workshopSalesforce Lightning workshop
Salesforce Lightning workshop
 
Lightning Chess, The fun way to learn the Lightning Component Framework
Lightning Chess, The fun way to learn the Lightning Component FrameworkLightning Chess, The fun way to learn the Lightning Component Framework
Lightning Chess, The fun way to learn the Lightning Component Framework
 

Similar to Lightning Components Workshop v2

Lightning Components Workshop
Lightning Components WorkshopLightning Components Workshop
Lightning Components Workshop
Gordon Bockus
 
Lightning salesforce
Lightning salesforceLightning salesforce
Lightning salesforce
mounikadv
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event Handling
WebStackAcademy
 
Paul Lammertsma: Account manager & sync
Paul Lammertsma: Account manager & syncPaul Lammertsma: Account manager & sync
Paul Lammertsma: Account manager & sync
mdevtalk
 
ADF and JavaScript - AMIS SIG, July 2017
ADF and JavaScript - AMIS SIG, July 2017ADF and JavaScript - AMIS SIG, July 2017
ADF and JavaScript - AMIS SIG, July 2017
Lucas Jellema
 
Displaying additional image types in XMetaL
Displaying additional image types in XMetaLDisplaying additional image types in XMetaL
Displaying additional image types in XMetaLXMetaL
 
MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...
MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...
MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...
MongoDB
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
Walid Ashraf
 
13 asp.net session19
13 asp.net session1913 asp.net session19
13 asp.net session19
Vivek chan
 
Flex Building User Interface Components
Flex Building User Interface ComponentsFlex Building User Interface Components
Flex Building User Interface Components
Ahmad Hamid
 
Optimizing Flex Applications
Optimizing Flex ApplicationsOptimizing Flex Applications
Optimizing Flex Applications
dcoletta
 
Lightning Talk: Mobile Cloud Jargon: Why is my iOS simulator not charging to ...
Lightning Talk: Mobile Cloud Jargon: Why is my iOS simulator not charging to ...Lightning Talk: Mobile Cloud Jargon: Why is my iOS simulator not charging to ...
Lightning Talk: Mobile Cloud Jargon: Why is my iOS simulator not charging to ...
Todd Kaplinger
 
Simple setup for an Angular EventEmitter
Simple setup for an Angular EventEmitterSimple setup for an Angular EventEmitter
Simple setup for an Angular EventEmitter
mike2071
 
Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development Mahmoud Hamed Mahmoud
 
Java Web Programming [8/9] : JSF and AJAX
Java Web Programming [8/9] : JSF and AJAXJava Web Programming [8/9] : JSF and AJAX
Java Web Programming [8/9] : JSF and AJAX
IMC Institute
 
Leture5 exercise onactivities
Leture5 exercise onactivitiesLeture5 exercise onactivities
Leture5 exercise onactivities
maamir farooq
 
Lecture exercise on activities
Lecture exercise on activitiesLecture exercise on activities
Lecture exercise on activities
maamir farooq
 
Asp.net tips
Asp.net tipsAsp.net tips
Asp.net tips
actacademy
 

Similar to Lightning Components Workshop v2 (20)

Lightning Components Workshop
Lightning Components WorkshopLightning Components Workshop
Lightning Components Workshop
 
Lightning salesforce
Lightning salesforceLightning salesforce
Lightning salesforce
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event Handling
 
Chapter 10
Chapter 10Chapter 10
Chapter 10
 
Paul Lammertsma: Account manager & sync
Paul Lammertsma: Account manager & syncPaul Lammertsma: Account manager & sync
Paul Lammertsma: Account manager & sync
 
ADF and JavaScript - AMIS SIG, July 2017
ADF and JavaScript - AMIS SIG, July 2017ADF and JavaScript - AMIS SIG, July 2017
ADF and JavaScript - AMIS SIG, July 2017
 
Displaying additional image types in XMetaL
Displaying additional image types in XMetaLDisplaying additional image types in XMetaL
Displaying additional image types in XMetaL
 
2310 b 05
2310 b 052310 b 05
2310 b 05
 
MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...
MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...
MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
 
13 asp.net session19
13 asp.net session1913 asp.net session19
13 asp.net session19
 
Flex Building User Interface Components
Flex Building User Interface ComponentsFlex Building User Interface Components
Flex Building User Interface Components
 
Optimizing Flex Applications
Optimizing Flex ApplicationsOptimizing Flex Applications
Optimizing Flex Applications
 
Lightning Talk: Mobile Cloud Jargon: Why is my iOS simulator not charging to ...
Lightning Talk: Mobile Cloud Jargon: Why is my iOS simulator not charging to ...Lightning Talk: Mobile Cloud Jargon: Why is my iOS simulator not charging to ...
Lightning Talk: Mobile Cloud Jargon: Why is my iOS simulator not charging to ...
 
Simple setup for an Angular EventEmitter
Simple setup for an Angular EventEmitterSimple setup for an Angular EventEmitter
Simple setup for an Angular EventEmitter
 
Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development
 
Java Web Programming [8/9] : JSF and AJAX
Java Web Programming [8/9] : JSF and AJAXJava Web Programming [8/9] : JSF and AJAX
Java Web Programming [8/9] : JSF and AJAX
 
Leture5 exercise onactivities
Leture5 exercise onactivitiesLeture5 exercise onactivities
Leture5 exercise onactivities
 
Lecture exercise on activities
Lecture exercise on activitiesLecture exercise on activities
Lecture exercise on activities
 
Asp.net tips
Asp.net tipsAsp.net tips
Asp.net tips
 

Recently uploaded

Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 

Recently uploaded (20)

Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 

Lightning Components Workshop v2

  • 1. Building Lightning Components Christophe Coenraets Developer Evangelist #TrailheadLive @ccoenraets
  • 3. What you will do Build an Account Locator built as a a set of loosely coupled components communicating through events Explore different deployment options: • Lightning App • Salesforce1 App • App Builder Composition AccountMap AccountList AccountLocator AccountListItem
  • 4. Step 1: Setting Up Your Environment
  • 5. 1. Sign up for a Developer Edition Org 2. Enable My Domain 3. Deploy to Users Challenge
  • 7. 1. Add a geolocation field to the Account object 2. Enter sample data Challenge
  • 8. Step 3: Creating an Aura-Enabled Controller
  • 9. Visualforce Page-Centric Model 1. Browser requests page Client Server 4. Browser renders html 2. Server executes Apex code 3. Server returns page (html + data) Show different data? Back to 1 Show different view? Back to 1
  • 10. Pros 1. Proven model 2. Productivity. Easy to implement 3. Naturally splits large apps into small, manageable units (pages) Caveats 1. Limited interactivity 2. Higher latency Visualforce Page Centric Model
  • 11. Lightning App-Centric Model 1. Browser requests Component Client Server 3. Browser builds UI with JavaScript 4. Browser requests data 7. Back to 3 2. Server returns Component Bundle 5. Server executes Apex 6. Server returns data (data only!) Show different data? Back to 4 Show different view? Back to 3
  • 12. Pros • Enables highly interactive/immersive user experiences • Less page refreshes • Tightly integrated (no iframe) • Composable Caveats • Higher learning curve compared to vanilla Visualforce pages • Higher level of complexity. Building an app is generally more complex than building a page Lightning Components App Centric Model
  • 13. Creating an Aura-Enabled Apex Controller public with sharing class AccountController { @AuraEnabled public static List<Account> findAll() { return [SELECT id, name FROM Account]; } } * You should add code to enforce CRUD and FLS
  • 14. 1. Create an Aura-enabled Apex controller named AccountController 2. Add a findAll() method that returns accounts that have location information Challenge
  • 15. Step 4: Creating the AccountLocator Component
  • 16. Anatomy of a Lightning Component <aura:component controller="AccountController"> <div> <div>AccountMap goes here</div> <div>AccountList goes here</div> </div> </aura:component>
  • 17. Component Parts: Component UI Markup Data binding Attributes Component
  • 18. Component Parts: Style UI Markup Data binding Attributes ComponentStyle Encapsulated CSS
  • 19. 1. In Lightning Applications 2. In the Salesforce1 app 3. In App Builder Where can I use Lightning Components?
  • 20. Using a Lightning Component in a Lightning App 1. Create a Lightning App File > New > Lightning Application 2. Embed the Lightning Component <aura:application> <c:AccountLocator/> </aura:application> Useful for creating fullscreen apps or for testing components during development
  • 21. Using a Lightning Component in the Salesforce1 App 1. Implement the force:appHostable interface <aura:component implements="force:appHostable"> 2. Create a Tab 3. Add the Tab to Mobile Navigation
  • 22. 1. Create the AccountLocator component 2. Add AccountLocator to the Salesforce1 App menu Challenge
  • 23. Step 5: Creating the AccountList Component
  • 24. Attributes • The data of the component • Available anywhere in the component • Examples: <aura:attribute name="price" type="Number"/> <aura:attribute name="title" type="String"/> <aura:attribute name="account" type="Account"/> <aura:attribute name="accounts" type="Account[]"/>
  • 25. Data Binding {! } <aura:attribute name="account" type="Account"/> <p>{!v.account.Name}</p>  Initial value of <p> is set to the value of account.Name  Value of <p> automatically updated when value of account.Name changes
  • 26. Bidirectional Data Binding <aura:attribute name="price" value="100" type="Number"/> <ui:inputNumber label="Principal:" value="{!v.price}"/>  Initial value of inputNumber is set to value of attribute (100)  Value of price attribute is updated when user types new value in inputNumber
  • 27. Component Parts: Controller UI Markup Data binding Attributes Component Event Handlers ControllerStyle Encapsulated CSS
  • 28. <aura:attribute name="counter" type="Number" default="0"/> <ui:button label="Click me" press="{!c.handleClick}"/> <div>{!v.counter}</div> handleClick: function(component, event) { var counter = component.get("v.counter"); counter = counter + 1; component.set("v.counter", counter); } ComponentControllerEvent Handler Example Counter
  • 29. Event Handler Example Retrieving Data on Init <aura:attribute name="accounts" type="Accounts[]"/> <aura:handler name="init" value="{!this}" action="{!c.doInit}" /> doInit : function(component, event) { var action = component.get("c.findAll"); action.setCallback(this, function(a) { component.set("v.accounts", a.getReturnValue()); }); $A.enqueueAction(action); } ComponentController
  • 30. Iterating through a List <aura:attribute name="accounts" type="Account[]"/> <aura:handler name="init" value="{!this}" action="{!c.doInit}"/> <ul> <aura:iteration items="{!v.accounts}" var="account"> <li>{!account.Name}</li> </aura:iteration> </ul>
  • 31. Nested Component • A component used in another component • AccountListItem Example: <aura:component> <aura:attribute name="account" type="Account"/> <li>{!v.account.Name}</li> </aura:component>
  • 32. Using a Nested Component <aura:attribute name="accounts" type="Account[]"/> <aura:handler name="init" value="{!this}" action="{!c.doInit}"/> <ul> <aura:iteration items="{!v.accounts}" var="account"> <c:AccountListItem account="{!account}"/> </aura:iteration> </ul>
  • 33. 1. Create the AccountList component responsible for displaying the list of accounts 2. Create the AccountListItem component that you nest inside AccountList to render individual accounts in the list Challenge
  • 34. Step 6: Creating the AccountMap Component
  • 35. • External JavaScript libraries and CSS style sheets must be loaded as static resources • Use the <ltng:require> tag to load them • Loading is asynchronous • afterScriptLoaded event is triggered after files have been succesfully loaded Loading External JavaScript Libraries and CSS Files
  • 36. Loading External JavaScript Libraries <ltng:require scripts="/resource/leaflet/leaflet.js"/>
  • 37. Loading External CSS Style Sheets <ltng:require styles="/resource/leaflet/leaflet.css" />
  • 38. Loading JavaScript Libraries and CSS Style Sheets <ltng:require scripts="/resource/leaflet/leaflet.js" styles="/resource/leaflet/leaflet.css" />
  • 39. Using the afterScriptLoaded Event <ltng:require scripts="/resource/leaflet/leaflet.js" styles="/resource/leaflet/leaflet.css" afterScriptsLoaded="{!c.renderMap}" />
  • 40. 1. Load leaflet JS library 2. Load Leaflet CSS 3. Render the map when files are loaded Challenge
  • 42. Intercomponent Communication Application Event Broker Event Object <aura:handler event="c:AccountsLoaded" action="{!c.accountsLoadedHandler}"/> <aura:registerEvent name="loaded" type="c:AccountsLoaded"/> var event = $A.get("e.c:AccountsLoaded"); event.setParams({"accounts": accounts}); event.fire(); AccountMapAccountList
  • 43. Creating the AccountsLoaded Event <aura:event type="APPLICATION"> <aura:attribute name="accounts" Type="Account[]"/> </aura:event>
  • 44. 1. Create the AccountsLoaded Event 2. Trigger the AccountsLoaded Event in AccountList 3. Handle the AccountsLoaded Event in AccountMap Challenge
  • 45. Step 8: Using Events to Center the Map
  • 46. Intercomponent Communication Application Event Broker Event Object <aura:handler event="c:AccountSelected" action="{!c.accountSelectedHandler}"/> <aura:registerEvent name="select" type="c:AccountSelected"/> var event = $A.get("e.c:AccountSelected"); event.setParams({"account": account}); event.fire(); AccountMapAccountList
  • 47. 1. Create the AccountSelected event 2. Trigger the AccountSelected event in AccountList 3. Handle the AccountSelected event in AccountMap and center the map on the selected account location Challenge
  • 48. Step 9: Interacting with the Salesforce1 App
  • 49. 1. Lightning Components enable you to extend standard features 2. Don't reinvent the wheel For example, if your component needs an account details view: use the standard one, don't create your own 3. Navigation between standard features and custom components should be smooth and feel integrated: users shouldn't notice they are switching between standard and custom features 4. Platform events allow you to integrate your custom components into the standard experience Salesforce1 Integration
  • 50. Firing a Platform Event var event = $A.get("e.force:navigateToSObject"); event.setParams({ "recordId": accountId }); event.fire(); This event will be handled be the Salesforce1 app which will then navigate to the account's details view
  • 51. Component Parts: Helper UI Markup Data binding Attributes Component Event Handlers Controller Shared Logic HelperStyle Encapsulated CSS
  • 52. When a user clicks a marker on the map, load the default Salesforce1 details view for the selected account Challenge
  • 53. Step 10: Using Components in App Builder
  • 54. Using a Lightning Component in App Builder 1. Implement the flexipage:availableForAllPageTypes interface <aura:component implements="flexipage:availableForAllPageTypes"> 2. Create a component description in the Design part <design:component label="AccountList"> </design:component> 3. Enable App Builder for Lightning Experience (PILOT) 4. Drag the component from the component palette in App Builder
  • 55. Compose AccountList and AccountMap in App Builder Challenge
  • 56. Summary UI Markup Data binding Attributes Component Design Descriptor Event Handlers Controller Shared Logic HelperStyle Custom Rendering Renderer Encapsulated CSS App Builder