Lightning Guide
Lightning Guide
Lightning Guide
Ans: Components used inside of App Builder. If you are a developer for salesforce orgs that has
heavily invested on visualforce pages then you can slowly move to lightning by creating
components and then embedding directly to visual force pages. This is possible because of
Lightning Out.
2. Winter 17 changes?
• SLDS extension Point (allows you to include latest version of salesforce lightning design
system library with only a single line of code)
• Base Lightning components (These components like menu item, tab sets, formatted number
and date times handle the html and css for you. They also handle accessibility as well as
validation and enhanced error messages.
• Data Lightning Service: It is simila to standard controller for visual force except it makes
working the data for Lightning components easier and efficient.
• Lightning actions: can be used to replace any custom buttons you have in your org.
• http://releasenotes.docs.salesforce.com
The <aura:component> has a aura which is actually the framework that the Lightning framework is
build on. Within this tag you can enter any valid web-enabled code such as HTML, JS and CSS. But
the best practice is to keep your component as simple and as small as possible
Unlike other frameworks where you can preview your componets, in Lightning, the components
need to reside inside a lightning component.
Even though you can use an application to contain html codes and other things but it is better to use
it as a container for your lightning components.
Even though you can use inline style to your component body, it is not recommended.
Note: If you want to style elements that are not first level then use .This and a space and the name
of the selector. If it is first level then you don’t use space
<aura:component>
<aura:attribute name=”whom” type=”String” default=”world” />
<h1 class=”title”> Hello {!v.whom}</h1>
</aura:component>
Working with UI Components
https://karna-dev-ed.lightning.force.com/auradocs/reference.app
//<aura:component >
<h1>Hello World</h1>
<ui:inputSelect class="single" aura:id="InputSelectSingle" change="{!
c.onSingleSelectChange}">
</ui:inputSelect>
</aura:component>
<aura:component > ({
<aura:attribute name="whom" type="String" onSingleSelectChange: function(cmp) {
default="world" /> var selectCmp =
<h1>Hello {!v.whom}</h1> cmp.find("InputSelectSingle");
<ui:inputSelect class="single" cmp.set("v.whom",
aura:id="InputSelectSingle" change="{! selectCmp.get("v.value"));
c.onSingleSelectChange}"> }
})
</ui:inputSelect>
</aura:component>
To make the component exposed to Lightning app builder we need to implement flexipage as
shown below.
<aura:component implements=”flexipage:availableForAllPageTypes”>
//other html tags or components here
</aura:component>
</aura:component>
MORE
<aura:component implements="flexipage:availableForAllpageTypes, force:appHostable"
access="global">
<aura:attribute name="whom" type="String" access="global" default="world" />
<h1>Hello {!v.whom}</h1>
<ui:inputSelect class="single" aura:id="InputSelectSingle" change="{!
c.onSingleSelectChange}">
</ui:inputSelect>
</aura:component>
Design
With sharing enable because this allows our component to enforce the organization’s security policy
atleast as far as record access is concerned.
SOQL stands for Salesforce Object Query Language. SOQL is only used to query data.
Security
Apex runs in a System Mode and it will return all data for every user. This means that lightning
components automatically enforce CRUD, which stands for CREATEUPDATTE, DELETE
permission automatically. Therefore, it is possible for you to create a component that exposes
sensitive data accidentally. The way this can be prevented is by adding the appropriate access
checks to any Aura-enabled method. If you are an experience Salesforce developer, you may be
thing with the sharing keyword , in the Apex controller for the open cases component that I’m
covered as far as security is concerned. But that only works what record a user has access to. It does
nothing to enforce CRUD or FLS defined in your salesforce ORG.
All aura-enabled methods should explicitly check for access prior to performing any queries or data
updates. This can be done using the isaccessible(), iscreateable(), isdeletable(), is updateable()
methods.
Map<String,Schema.SObjectField> caseMap =
Schema.SObjectType.Case.fields.getMap();
for (String field : caseFields) {
if (!caseMap.get(field).getDescribe().isAccessible()) {
System.debug('This field was not accessible: ' + caseMap.get(field));
return null;
}
}
return [SELECT Id FROM Case
WHERE IsClosed = false AND OwnerId
= :UserInfo.getUserId()];
Lightning components interact with salseforce1 with events and there are several imp events that
come up with the force namespace.
The navigateToSObject event will navigate to user to the list view for whatever id is specified.
Its top level namespace for creation of components, getting a component, setting a
component, Enqueuing Action, Running an Action.
//component
<div>
<div onclick="{!c.goToRecord}"></div>
<force:recordView recordId="{!case.Id}" type="MINI" />
</div>
//controller
goToRecord : function(cmp, event, helper) {
var sObjectEvent = $A.get("e.force:navigateToSObject");
sObjectEvent.setParams({
"recordId": cmp.get("v.case.Id"),
"slideDevName": 'detail'
})
sObjectEvent.fire();
}