What is Wrapper Class and How to use it with LWC, Oleh Mykytyn
CzechDreamin
231 views
11 slides
Jun 15, 2022
Slide 1 of 11
1
2
3
4
5
6
7
8
9
10
11
About This Presentation
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 wrap...
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.
Size: 6.69 MB
Language: en
Added: Jun 15, 2022
Slides: 11 pages
Slide Content
What is Wrapper Class and How to use it with LWC by Oleh Mykytyn
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: [email protected] Twitter: @oleh_mykytyn
Today’s Agenda What is Wrapper Class Benefits of Wrapper Class Wrapper Class Use Cases in LWC Best Practices Demo Q & A
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.
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.
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, Visualforc e 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
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.
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