Salesforce Lightning Tutorial

Salesforce Lightning Tutorials with Sample Code

Salesforce Lightning Framework is the Customer-focused UI designed to build powerful dynamic apps for mobile, web, and desktop devices. The task of a Salesforce developer is building Lightning components and administrator assembles those pages to create a lightning page. Before we dive deep into the Salesforce Lightning Component framework with sample code, let us first discuss why we need the Salesforce Lightning components and what are the benefits?

  • Lightning Components are named as out-of-the-box components helps to improve app building experiences and they don’t need any optimization as taken care of themselves only.
  • They are responsible for enhanced performance because we are using stateless server and depends on JavaScript to deal with UI components, metadata, and the application data. In this case, the total number of server calls are reduced and they are made whenever necessary.
  • It is based on the event-driven architecture that promotes development work, compatibility across browsers, and this is a component rich ecosystem.

Let us discuss the Lightning component framework in detail below.

What is the Lightning Components Framework?

This is UI framework designed to develop dynamic apps for both mobile and the desktop devices. The framework utilizing JavaScript language at the client side and the APEX language on the server side as shown below in the diagram.

With the help of this Framework, developers can design more powerful and unique apps. This framework was initially launched for mobile devices but later modified for desktop devices too. The main objective of this framework is developing a single page application. Here are some of the popular reason why you need Lightning components.

●       Lightning components can be used in multiple ways like org customization, building standalone apps, event apps etc. With the help of Lightning out, these apps can be quickly hosted to other platforms too.

●       With the help of community builder or Lightning app builder, components are easy to design with drag and drop operations only.

●       This is easy to add components in a lightning page, standalone apps or event apps as a quick action.

●       The components allow app building faster and there is no need of starting development work from scratch.

●       The browser events are easy to capture when you add components within a Lightning page.

●       The components are easy to share with other Lightning users.

●       With the help of JSON, data can be exchanged between the client and server quickly.

●       This UI framework supports the latest browser technologies like CSS, HTML, or touch events etc.

What is Aura open-source Framework?

The UI Lightning framework is based on Aura open source framework. This is an open source framework where something is available for free and it can be further customized quickly based on org needs. When building Lightning apps, the use of aura keyword is common everywhere and it is easily available online to download for free.

The sample code is given below using aura keyword:

We have used the word Lightning component a couple of time till now. So, you must be wondering what is a Lightning component actually? Further, we will discuss the components in details and how to create a Lightning Component in Salesforce.

What is Salesforce Lightning Component?

A component is a set of files written so nicely that they have the capability to accomplish a specific business goal. They are loosely coupled set of codes and taken as the building blocks for Lightning Framework. Encapsulating a reusable and modular piece of UI, it may range from single line to the complete application.

Components are saved with the suffix .cmp and it should start with an alphabet containing alphanumeric and one underscore character. This is generally unique in the namespace. Whitespaces are not allowed when naming components and it ends with one or two consecutive underscores. A component is a set of resources or files as discussed earlier. So, what are the other resources? Let us discuss in detail below –

ResourceResource NameUsage
Component or Appsample.cmp or sample.appIt contains all markup components and each bundle has only one component.
CSS StylesSample.cssIt contains all components styles.
DesignSample.designIt is needed by the component to be used with app builder or community builder.
ControllerSamplecontroller.jsIt contains client-side controller methods to handle events.
DocumentationSample.auradocIt contains the component description, sample code, and other component references too.
Helperamplehelper.jsIt contains JS functions that can be called later during coding.
SVGSample.svgThis is a custom icon resource for components to be used with app builder or community builder.
RendererSamplerendered.jsThis is required to override default rendering for a component.

How to create a Lightning Component?

To create a Lightning Component, you need to click on Developer console tab then click ‘create component’ tab. It will open a dialog box where you have to give the name of components as per the naming rules suggested earlier. For example, if the name of the component is HelloGlobe then it will be saved automatically with the name HelloGlobe.cmp and the basic sample code for this component can be written as –

The output of this component would be Hello Lightning! as written between markup tags.

Final Words:

With this tutorial guide, we have a clear idea of the framework, components, and its related resources, how to create a new Lightning Component in Salesforce. To know more about Salesforce Lightning framework and how to create complex components, you should join Salesforce certification program at JanBask Training for a depth understanding of the concept.

0 Comments

Leave a Reply

CONTACT US

We're not around right now. But you can send us an email and we'll get back to you, asap.

Sending

About Us

Forcetalks is a Salesforce collaboration platform for coders & developers, geeks & nerds, consultants & business heads, admins & architects, managers & marketers and of course the business owners. A community where you can learn from, where you can contribute to. For you. For Salesforce. Read More...

Copyright 2018 Forcetalks. All Right Reserved.

Log in with your credentials

or    

Forgot your details?