You will require to use Lightning: recordForm, Lightning: recordEditForm, Lightning: recordViewForm, force: recordData.
We use the aura: a method for defining the method within the API of the component. This allows us to call a method directly in the client-side controller of a component rather than handling or dismissing an event. Through <aura: method>, we can simplify the code which the parent component requires for calling a method on the child component.
The AuraEnabled annotation allows the lightning components for accessing the Apex properties and methods. AuraEnabled annotation is overloaded, and we use it for distinct purposes.
1. We use AuraEnabled on the Apex class static methods for making them accessible like remote controller actions in our lightning components.
2. We use @AuraEnabled on the Apex Instance methods and properties for making them serializable when we return the class instance like the data from the server-side action.
The major differentiation lies in the fact that Lightning components are built based on the component framework, they are well-adapted to mobile, and are centered around the client. On the other hand, Visualforce components revolve around the page itself with the server being the place where the majority of work takes place.
In general, it is considered good practice to give preference to Component Events over Application Events. Application Events are used for signaling a message to a broader audience, whereas Component Events are tied to a hierarchy and can limit receiving the message to only those components that should be notified about it.
Three phases are available for application event propagation when the event fires: capture phase, bubble phase, and default phase.
Two phases are available for component event propagation after the event fires: capture phase and bubble phase.
Aura components canâ€™t be included in a Lightning Web component because it isnâ€™t possible to add generic elements to custom components (in other words, a parent Lightning Web component can only be made up of Lightning Web components). Nevertheless, by contrast, you may include Lightning Web components into Aura components (i.e. parent Aura components can contain both Aura Components and LWC). Moreover, they can handle each otherâ€™s events.
With a responsive design in mind, Lightning components are meant to be mobile-first. The components help to build responsive apps faster for desktops, tablets, and mobile.
We use the component event for interaction between the parent and child. We can communicate the change in the child component to the parent component through the component event. We use Application events to send any modification in the component to a wide audience. The components registered for this event will get an alert.
As with all Apex to be used within any Lightning component, the methods must first be set to be â€œAura Enabledâ€, using the Apex annotation â€œ@AuraEnabledâ€, exposing the method to the Lightning components. Furthermore, the annotation must be expanded to state that it is cacheable like â€œ@AuraEnabled(cacheable=true)â€. This annotation disables all DML operations, meaning the method only returns data, never mutates it. The method can then be imported into the LWC, like any other, and used as a wire adapter.
The wire service is a data provisioning service which streams new data as it becomes available. It supports reactive variables, allowing new data to be provisioned as the context changes. The source of the data can either be from a Salesforce module, or a developer defined Apex class.
By using Lightning App Builder, we can create lightning record pages. Following are different types of lightning record pages:
1. Record page
2. App page
3. Home page
By using Lightning out, we can embed the lightning component on the VisualForce page. We can add the lightning component to the VisualForce page in three steps:
2. After that, we can generate and point a lightning app that we use for the component dependencies.
Attributes are variables that we use for storing the values. We must define the Default, Type, Name, Access, and Description in the attribute definition. In the attribute definition, only Name and Type are the required parameters.
If we want to use our component on the external site, we have to use lightning out. The advantage of lightning out is we can utilize lightning components in a visual force page.
When the style classes provided by SLDS donâ€™t meet our requirements, we are still able to provide our own styles to achieve what we need in both Aura and LWC. The process is pretty similar in both frameworks: we create a CSS file which matches the name of the component in its folder and place our styles there. In LWC, the styles of our components are completely encapsulated and donâ€™t overflow into other components. In Aura we prefix all our styles with â€˜.THISâ€™, but our styles can affect child components.
In situations where an event can be frequently fired based on a user interaction, itâ€™s important we handle those events in a specific way so as to not cause a detrimental impact to the userâ€™s experience. A good example for this is a search bar which filters a list when a user types into it, if we were handling the â€˜onchangeâ€™ event, we would end up filtering after every keypress and this would cause the search to appear sluggish to the user. Instead what we want to do is set a timeout after every keypress, if the user continues to type within a small time frame (say 500ms), we simply cancel the previous timeout and start a new one. Now we only take the performance hit when we know the user has done something valid and the filtering appears smooth. This technique is called debouncing.
Some of them are:
* Default phase
* Bubble phase
* Capture Phase
Some of them are:
* Default phase
* Bubble phase
* Capture Phase
Lightning components can be used in frequent places, including the Lightning App Builder and Community designer, in divide separate applications, as well as in Lightning Experience Record Pages, Lightning Pages etc. The advantage they could also be displayed in the direction-finding bar, in the App Launcher, and as a Quick act.
Lightning component is lightning experience ready by default and is also compatible in Salesforce1 App, it has a responsive layout therefore it adjust its resolution according the screen size and therefore can be used on desktop as well without writing any separate code.
It is always a good idea to use a component event over an application event. Component events can be handled only by the components which are above them in the hierarchy of containment. Thus, the usage is limited to the components which need to know them.
Application events are best used when something is handled at the application level, like navigating to a particular record. Application events permit any communication between the components which are in separate parts of the application and have no direct containment relationship.
Component Events: these are used when the parent and child need to communicate. They make use of bubbling and capture, just like it is used in DOM events. A change in a child component will be communicated to the parent component through the component event.
Application Events: these are basically used for communicating any kind of change in the component to a larger audience. Any component which has been registered for this event will get notified.
Aura is an open-source framework which is one of the ways to create Lightning components that are reusable units. This original programming model is thought to be the â€œbasicsâ€ for building components. The other more modern method, Lightning Web Component, is very different from it. The process of migrating Aura components to Lightning Web components isnâ€™t linear, therefore it makes sense to apply Lightning Web for making new components and sticking with the Aura components for older ones that you already have in Aura.
It isnâ€™t right to call Salesforce Lightning a model-view-controller framework as it is component-based.
The Aura: method tag can be used for defining a method for component API. So, there is no need to fire and handle a component event, and it allows us to directly invoke the method in the componentâ€™s controller on the client-side. It also helps to simplify the code required for a parent component to call a method on a child component that forms a part of the parent component.
Of course, we can do this. The styles can be inherited from parents and not necessarily defined in the component.
Following are the component bundles of the lightning components:
Controller: Controller tackles the client-side events.
Style: It includes component style.
Documentation: We use this component bundle for recording the componentâ€™s use.
Renderer: The renderer component bundle contains a component default rendering behavior.
Helper: we can write the general logic in the helper that is used by various controller methods to avoid repetition.
We use lightning data service for creating, deleting, editing, or loading a record in our component without Apex code. It handles field-level security and sharing rules. Lightning data service enhances the user interface and performance consistency. The lightning data service's main advantage is we can carry out basic tasks without Apex code.
To share code between Aura components, we create a service component. This is an Aura component which uses â€œaura:methodâ€ to expose the pieces of code which are to be shared. This component can then be included in other components and the shared pieces of code called.
Aura components can contain and utilise LWCs, including communicating with them via events and component methods. However, the opposite is not true, an LWC cannot be composed of Aura components, and they can only ever be its parent.
Code can also be shared between Aura and LWC components using an ES Module.
The lightning design system provides style guides and advanced UX best practices for building pixel-perfect applications that match the feel and look of the salesforce1 mobile app and lightning experience.
A bundle includes Aura definitions and their associated resources. The aura definition can be an application, interface, component, and event. Aura Definition Bundle element is a folder that includes definition files, contrary to other metadata components, the aura definition bundle component is not a single file; it is a group of files.
Following are the different types of events of salesforce lightning components:
> System Events: During the lightning app lifecycle, salesforce fires the system events.
> Application Event: The application event extent is across the lightning application, and any element that has enrolled for his event will get an alert.
> Component Event: The component event scope is within itself, or within the parent component of this event, all the parent components will get an alert.
Lightning experience is the name for the latest salesforce desktop application, with the latest features, developed with an advanced User Interface(UI) and speed optimization.
Aura is a freeware technology that powers the lightning components. Aura: namespace comprises all the main building blocks to define applications and components.
The developer can add the Aura components to the Visualforce page in the following three ways:
* Create a reference to a Lightning app for declaring component dependencies.
Visualforce components are page-centric and work is mostly server-based. Lightning components, on the other hand, are client-side centric which accounts for their dynamic, mobile-friendly nature.
Not really. Lightning is a framework based on components.
Yes, it does work with Visualforce.
It is possible to use Lightning components, Salesforce 1 mobile app, custom standalone apps directly in Lightning Experience as well as template-based communities. Lightning components are used in the Visualforce page, for use in Salesforce Visualforce communities as well as the classic environment.
We first create a Lightning tab for the Lightning component and subsequently include the tab in the navigation select list of Salesforce 1 mobile app and then the newly created tab to it.
The Lightning components can be used in the following ways:
* Drag-and-drop components are meant for the Lightning App Builder and Community Builder.
* Add Lightning Components for Lightning Pages.
* Add Lightning Components for Lightning Experience Record Pages.
* Launch a Quick-action Lightning Component.
* Overrule the Lightning Componentâ€™s standard actions.
* Create custom applications
The components act as functional units of the Lightning component framework. A reusable, modular section of UI is encapsulated within the components. They can range from a single line of text up to the entire application in terms of granularity.
From the admin side, the Lightning version provides various customization leverages, including the framework with reusable low-code blocks that admins can use to build components and put them on multiple pages via easy drag and drop. Plus, the Appexchange offers many off-the-rack plugins, components, and applications that can be plugged in from the Appexchange.
Lightning is an enhanced and upgraded Salesforce platform version that was created for simplifying the process of building apps, quickly customizing the ecosystem to boost the efficiency and productivity of internal users and their work, as well as for connecting with customers and making their experience better.