Sunday, 28 February 2016

Lightning Events Via Visualforce

This post is again as per request from one of my friend .He wanted me to put together a simple demonstration of how to handle lightning events from visualforce and how to publish or fire lightning events from outside salesforce .Both of these cases are extremely common if you are building application using lightning for visualforce .

If you have already started adopting Lightning component framework ,you probably know how important are Events .There are two types of events , Application events and Component Events .Please note that prerequisite for understanding this blog is understanding of events in context of lightning component framework .

The below code snippets apply to only application events .

Application events are handled by all components that are listening to the event. These events are essentially a traditional publish-subscribe model.


1. Firing Events from the Visualforce and Handling the Events in lightning components


To demonstrate this ,lets create a simple event file and fire the event from the visualforce inside the callback and handle the event back in the lightning component file

Below is the component set up for lightning framework

Lets put together the visualforce code needed for the experiment

Here are the exciting results











Now this opens a world of new opportunities to mash up already existing visualforce UI with lightning component framework.


One sample project that i experimented is in my git repo which takes map component as a lightning component but receives pickers from the visualforce select option .


2.Firing events from the lightning component and handling the event inside visualforce


This is another interesting observation ,you can fire an event from the lightning component and handle the event inside visualforce .

Lets see the hello world code for this scenario

The visualforce code is as below

Fun part




I hope this opens up a whole world of new directions to design and build some excellent mashups with visualforce and lightning .

Please reach out via my twitter @msrivastav13 or mail msrivastav13@gmail.com.

14 comments:

  1. You have written a very effective blog for readers, thank you so much to share this useful information. If you want best Trucking Insurance in US then you should visit our website.
    Great post friend, Thank a lot to share this. You are doing good job. Keep posting.
    Salesforce Consulting India

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Thanks for sharing, nice post! Post really provice useful information!

    Hương Lâm chuyên cung cấp bán máy photocopy và dịch vụ cho thuê máy photocopy giá rẻ, uy tín TP.HCM với dòng máy photocopy toshiba và dòng máy photocopy ricoh uy tín, giá rẻ.

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. Yes i am totally agreed with this article and i just want say that this article is very nice and very informative article.I will make sure to be reading your blog more. You made a good point but I can't help but wonder, what about the other side? !!!!!!Thanks via4d

    ReplyDelete
  6. I was surfing the Internet for information and came across your blog. I am impressed by the information you have on this blog. It shows how well you understand this subject. via4d

    ReplyDelete
  7. Nice post! This is a very nice blog that I will definitively come back to more times this year! Thanks for informative post. via4d

    ReplyDelete
  8. Nice post! This is a very nice blog that I will definitively come back to more times this year! Thanks for informative post.
    event

    ReplyDelete
  9. Thanks a lot for sharing a valuable blog on Salesforce lightning. I was browsing through the internet looking for salesforce lightning and came across your blog. I am impressed by the information that you have on this blog. It shows how well you understand this subject, you can find more information about Salesforce lightning here:
    Salesforce lightning interview questions and answers
    Salesforce lightning

    ReplyDelete
  10. """Dear Admin,
    I am Universal Investment Strategies. Very informative post! I am thankful to you for providing this unique information.
    Universal Investment Strategies provides one-on-one options trading mentorship and education to investors seeking to generate active, passive and/or retirement income. With over 25 years of combined experience and thousands of satisfied customers, Universal Investment Strategies was founded on the principals of we will walk with you side by side every step of the way.​
    Universal Investment Strategies LOS ANGELES CA
    Online Stock Trading
    Best Options To Trade
    Learn How To Trade Stocks
    Best Trading Courses
    Best Way To Learn Stock Trading"""

    ReplyDelete

  11. Thanks, this is generally helpful.
    Still, I followed step-by-step your method in this salesforce cpq online training
    salesforce cpq course

    ReplyDelete

Introducing Lightning Base Components

Lightning Base Components are great addition to the platform and in fact revolutionary .One of the concerns around lightning component ...