How To Display Lightning Component In Visualforce Page

Lightning Components for Visualforce is based on Lightning Out, a powerful and flexible feature that lets you embed Lightning components into almost any web page. When used with Visualforce, some of the details become simpler. For example, you don’t need to deal with authentication, and you don’t need to configure a Connected App.

In this example, we will see a very basic example of the lightning component and then display lightning component in the visualforce page.

Lightning Component LightExample1

<aura:component><div><h1> This is lightning component for visualforce page</h1></div></aura:component>

Lightning App LightExampleApp1

Here important point is that ltng:outApp needs to be extended in app.

ltng:outApp adds SLDS resources to the page to allow our Lightning components to be styled with the Salesforce Lightning Design System. If we don’t want SLDS resources added to the page, we need to extend from ltng:outAppUnstyled instead.

<aura:application extends="ltng:outApp" access="GLOBAL"><aura:dependency resource="c:LightExample1" /></aura:application>

Visualforce page LightningExampleVF1

<apex:page showHeader="false" sidebar="false"><apex:includeLightning />    <apex:includeScript value="/lightning/lightning.out.js" /><div id="LightningComponentid" />    <script>$Lightning.use("c:LightExampleApp1", function() {$Lightning.createComponent("c:LightExample1",{ },"LightningComponentid",function(cmp) {console.log('Display Lightning component in visualforce page');});});</script></apex:page>

Use Lightning Components in Visualforce Pages output

In the above Visualforce page, apex:includeLightning tag imports necessary dependencies and scripts to enable Visualforce to act as Lightning component container.

We can use $Lightning.createComponent create Lightning Component dynamically.

We can call $Lightning.use() multiple times on a page, but all calls must reference the same Lightning dependency app.

Permanent link to this article: https://salesforcebuddy.com/2020/01/how-to-display-lightning-component-in-visualforce-page/

How to rename Lightning component

We can run below query in developer console query editor. It will return all the aura component name in DeveloperName column.


SELECT Id, DeveloperName, MasterLabel FROM AuraDefinitionBundle

Now we can edit Developer Name, MasterLabel and save it.

It will reflect all the place wherever the component is used. If you are using the component in controller and helper, It will reflect there also.

Permanent link to this article: https://salesforcebuddy.com/2020/01/how-to-rename-lightning-component/

Salesforce Deployment Using ANT Migration Tool – Part 3

Please follow the steps below to setup ant in your machine

  1. Download ANT from http://ant.apache.org/bindownload.cgi
  2. Extract the downloaded zip file somewhere like C:\apache-ant-1.9.4-bin\apache-ant-1.9.4
  3. Set this path in system variables as ANT_HOME.
  4. If PATH system variable already exists then add %ANT_HOME% to your path variable, else add new PATH variable and keep this value.
  5. Also create a JAVA_HOME environment variable and set the value to the location of your JDK.
  6. Go to command prompt and type ant -v. If it shows that ‘Apache Ant Version compiled’ then that means we are good to go.
  7. Till here you have downloaded and configured the required steps for ANT. Now you have to download the Force.com migration tool from your salesforce org ( it can be any org ). Go to Your Name > Setup > Develop > Tools.
  8. Click the “Force.com Migration Tool” link to download a zip file. Inside this zip file you can find the ant-salesforce.jar file and some sample configuration files.
  9. Copy the jar file mentioned above and paste it into the lib folder of your ant installation direcotry ‘C:\apache-ant-1.9.4-bin\apache-ant-1.9.4\lib‘.
  10. Now, you are ready to use ANT with force.com migration tool. You can now deploy or retrieve your salesforce.com Metadata using ANT and command prompt.

Retrieve Code

Deploy Code

Permanent link to this article: https://salesforcebuddy.com/2019/04/salesforce-deployment-using-ant-migration-tool-part-3/