SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.
SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.
Successfully reported this slideshow.
Activate your 30 day free trial to unlock unlimited reading.
What is Wrapper Class and How to use it with LWC, Oleh Mykytyn
At some point in time, each salesforce developer meets with the Wrapper class as it gives some extra flexibility to us. You’ve probably already worked with it in Aura Component or Visualforce but what about Lighting Web Component? Do we have such a possibility there and if yes, how can we use wrappers there, and easily connect it with Apex.
At some point in time, each salesforce developer meets with the Wrapper class as it gives some extra flexibility to us. You’ve probably already worked with it in Aura Component or Visualforce but what about Lighting Web Component? Do we have such a possibility there and if yes, how can we use wrappers there, and easily connect it with Apex.
What is Wrapper Class and How to use it with LWC, Oleh Mykytyn
1.
What is Wrapper Class
and How to use it with LWC
by Oleh Mykytyn
2.
#CD22
Introduction
Oleh Mykytyn
10x Certified
Lviv's Salesforce Developer Group Leader
Lviv's Salesforce Saturday Founder
Salesforce MVP class 20/21
Salesforce Tech Lead & Strategic Relationship Director
at Redtag
Email: oleh.mykytyn@redtag.pro
Twitter: @oleh_mykytyn
3.
#CD22
Today’s Agenda
1. What is Wrapper Class
2. Benefits of Wrapper Class
3. Wrapper Class Use Cases in LWC
4. Best Practices
5. Demo
6. Q & A
4.
#CD22
Salesforce Stands With Ukraine
As the war in Ukraine persists with its heartbreaking impact on
the courageous Ukrainian people and their loved ones around
the world, we’re continuing our support of humanitarian efforts
in the region.
Together with our employees we’ve now donated more than
$4 million USD to address basic needs, support refugees, and advance food security
across Ukraine.
We’re encouraging our employees to continue to donate to our trusted nonprofit
partners and Salesforce will continue to match those donations.
5.
#CD22
What is Wrapper Class?
A wrapper class is a data structure, or an abstract data type which
can contain different objects or collections of objects as its
members.
Wrapper class is similar to a custom object but it is an class created
in Apex and whose instances could be different data type like
primitive, collections or sObjects.
6.
#CD22
Benefits Of Wrapper Class in Salesforce
● Consolidate a set of different data from multiple Objects
● Helps to combine different types of appropriate data and organize it efficiently
● Good approach for code reusability
● Can be used in Lightning Web Component, AURA, Visualforce and Apex
● Possibility to convert the JSON string into object and vice versa
● Multiple wrapper and nested classes can be used in a single Class
7.
#CD22
Wrapper Class Use Case in LWC
● Display a table of records which contains combined data from
several objects in one row, for example Order Item and
Product Warranty.
● To show data received from another system via REST API.
Without same data model in Salesforce we can easy convert
JSON into Wrapper and display it for user.
● Display a list of records with checkbox and possibility to select
multiple records and to do some actions with them. And for
this checkbox we don’t need to save data in object.
8.
#CD22
Wrapper Class Best Practices
● Using Wrapper Class is a best practice
● Create a separate Apex Class for your Wrapper Class
● Keep inner nested Wrapper Class at the end of your Apex Class
● Use all Object-oriented principles that allow to accomplish code
reusability
● Always try to keep it as much unified as possible
● Keep it clean and good structured which will help understand it’s
usage