ads

Thursday, 27 April 2017

Leaflet: Make a web map In Salesforce with PopUp Image Icon and making Marker Cluster



Before copy and Paste below Visualforce page code and Controller code make sure you have done
below things which I have detailed explained in my Previous blog.

1) Downloaded All thee and saved them in Static Resource
     1)  Download leaflet
     2)  Download Leaflet markercluster
     3)  Download Jquery

2) Download the CSV file and Import them in Pinpint Custom object.
     1)Download Lat Long Coordinate File

3) You have made three custom label and fill the value in them which I have explained above.

 Label 1:- FeatureCollection


1
2
3
{
   "type": "FeatureCollection",
   "features": [

   Label 2:- LatlongName


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
{
    "type": "Feature",
    "geometry": {
       "type": "Point",
       "coordinates":  [ longitude,latitude ]
    },
    "properties": {
    "LOCATION_STREET_NAME":"streetName",
    "Range":"RangeValue"
    }
  },
 
Lable 3:- last


1
2
]
}

 4) Download Below Icons and save them in Static Resource . We will use as Custom Marker Icons .
    1)  GreenLeaf
    2)  YellowLeaf
    3)  Redleaf
    4)  Rat

Now if you have done all Four points above you are ready to go .You can now Copy and Paste below visualforce page and Controller code.

Controller Code :-


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
public class DemoLeafletClass {
    
    public list<pinpoint__c> pinList{get;set;}
    
    public String FinalStr{get;set;}
    public String HunRec{get;set;}
    
    String[] stringListmiddle = new String[0];
    
    public DemoLeafletClass (){
        
        
        pinlist = [select id,name,latitude__c,longitude__c,Pop_up__c,Range__c from pinpoint__c ];
        
        string middle ;
        
        for(pinpoint__c p:pinlist){
                        
            middle = System.Label.latlongname;
            middle = middle .replace('longitude', string.valueof(p.longitude__c));
            middle = middle .replace('latitude', String.valueof(p.latitude__c));
            middle = middle .replace('streetName', p.name);
            
            middle = middle .replace('RangeValue',string.valueof( p.range__c));            
            stringListmiddle.add(middle);            
        }
        
        FinalStr = String.join(stringListmiddle, ' ');        
        FinalStr = System.Label.FeatureCollection+FinalStr +System.Label.last;                
    }                
}

Visualforce Page:-


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<apex:page controller="DemoLeafletClass" >
<apex:form style="width:900px">
<apex:pageblock >
<div align="center" draggable="false" >
        <apex:commandButton value="Reload"  onclick="load();" reRender="map"  styleClass="myClass"/>    
        &nbsp;&nbsp;&nbsp;&nbsp;
        <apex:commandButton value="Clear Marker"  onclick="clearmarker();" reRender="map" styleClass="myClass" />                 
   </div>
 </apex:pageblock>
  </apex:form>
<html>
<head>
  <title>A Leaflet map!</title>
 <title>A Leaflet map!</title>

  <link rel="stylesheet" type="text/css" href="{!URLFOR($Resource.leaflet, '/leaflet.css')}"/>  
  <link rel="stylesheet" type="text/css" href="{!URLFOR($Resource.MarkerCluster, 'markercluster/dist/MarkerCluster.css')}"/>  
  <link rel="stylesheet" type="text/css" href="{!URLFOR($Resource.MarkerCluster, 'src/MarkerClusterGroup.Refresh.js')}"/> 
  <link rel="stylesheet" type="text/css" href="{!URLFOR($Resource.MarkerCluster, 'markercluster/dist/MarkerCluster.Default.css')}"/> 

  <script type="text/javascript" src="{!URLFOR($Resource.leaflet, '/leaflet.js')}"></script>  
  <script type="text/javascript" src="{!URLFOR($Resource.MarkerCluster, 'markercluster/dist/leaflet.markercluster.js')}"></script>  
  <script type="text/javascript" src="{!URLFOR($Resource.jquery, '/jquery-2.1.1.min.js')}"></script>
  
  <style type="text/css">
.myClass{
padding: 10px;
color:white !important;
background:#00CC00 !important;

            
}
</style>
    <style>
    #map{ width: 900px; height: 600px; }
  </style>
</head>
<body>

  <div id="map"></div>

  <script>
  var rodents;

  var clusters;
  
  var markIcon = L.icon({
                    iconUrl: '{!$Resource.Greenleaf}',
                    iconSize: [25,35]
                });
  

  // initialize the map
  var map = L.map('map').setView([42.35, -71.08], 13);
// load a tile layer
  L.tileLayer('http://tiles.mapc.org/basemap/{z}/{x}/{y}.png',
    {
      attribution: 'Tiles by <a href="http://mapc.org">MAPC</a>, Data by <a href="http://mass.gov/mgis">MassGIS</a>',
      maxZoom: 17,
      minZoom: 9
    }).addTo(map);
  
  function load(){        
          
      rodents = L.geoJson({!FinalStr} ,{
    pointToLayer: function(feature,latlng){
     var marker = L.marker(latlng,{icon: markIcon });
        marker.bindPopup(feature.properties.LOCATION_STREET_NAME+ '<br/>' + feature.geometry.type);
        return marker;
    }
  });
     
     clusters = L.markerClusterGroup();
       clusters.addLayer(rodents);
     var showAllPoint =  map.addLayer(clusters);
       
       map.fitBounds(showAllPoint.getBounds(), {
            padding: [50, 50]
        });                 
    }
    
    function clearmarker(){    
    map.removeLayer(clusters);
    }
    
    
   
  
  </script>
</body>
</html>

</apex:page>

Output Screen 1 :  After clicking on "Reload"  button.


Output Screen 2 :


Wednesday, 26 April 2017

Leaflet: Make a web map In Salesforce

Hello Guys,

This post is regarding using Leaflet in salesforce .If you want to work on Leaflet I advise you to
first read this original article on Leaflet which is based on GeoJson and Json Files.

Leaflet: Make a web map!

Now First there are few things you need to download and save them in Static Resource and Custom Label in salesforce . This Static Resource and Custom label we are going to use in our Apex Class.

1)  Download : leaflet
2)  Download : Leaflet markercluster
3)  Download : Jquery

We will use all three above file in Static Resource. Example Below


  You need to save this file in Static Resource and it should look like below screenshot

   Leaflet :-





  MarkerCluster :-



  Jquery :-
 


4) Download Lat Long Coordinate File
   We will use this above file to fetch records from Pinpoint Custom object in Salesforce.
   you can download this file and Import all records in Pinpoint Object in Salesforce.

    For this you need to create a Custom object "Pinpoint" and create few custom fields.
    Below I have provided the structure of this "Pinpoint" Object.
 
   Screenshot 1:




   Screenshot 2:
 


   5) Custom Label :- Three Custom Label you need to create in Salesforce .If you want you can edit
       those label with your fields name. We will use these three labels in our controller class later like
       in below example.



      Label 1: -  FeatureCollection
     
 
    You can also Copy and Paste Value Text from below

{
   "type": "FeatureCollection",
   "features": [


      Label 2:-  LatlongName


    You can also Copy and Paste Value Text from below

{
    "type": "Feature",
    "geometry": {
       "type": "Point",
       "coordinates":  [ longitude,latitude ]
    },
    "properties": {
    "LOCATION_STREET_NAME":"streetName",
    "Range":"RangeValue"
    }
  },


      Label 3 :- last

You can also Copy and Paste Value Text from below

]
}

6) Download Below Icons and save them in Static Resource . We will use as Custom Marker Icons .
    1)  GreenLeaf
    2)  YellowLeaf
    3)  Redleaf
    4)  Rat

Finally.....
we are ready to show our latitude and longitude which exist on Pinpoint Custom Object to
a map using Leaflet APIs.
Before copy and Paste below Visualforce page code and Controller code make sure you have done
below things which i have explained in my blog above

1) Downloaded All thee and saved them in Static Resource
     1)  Download leaflet
     2)  Download Leaflet markercluster
     3)  Download Jquery

2) Download the CSV file and Import them in Pinpint Custom object.
     4)Download Lat Long Coordinate File

3) You have made three custom label and fill the value in them which I have explained above.
 
 Label 1:- FeatureCollection


1
2
3
{
   "type": "FeatureCollection",
   "features": [

   Label 2:- LatlongName


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
{
    "type": "Feature",
    "geometry": {
       "type": "Point",
       "coordinates":  [ longitude,latitude ]
    },
    "properties": {
    "LOCATION_STREET_NAME":"streetName",
    "Range":"RangeValue"
    }
  },
   
Lable 3:- last


1
2
]
}

 4) Download Below Icons and save them in Static Resource . We will use as Custom Marker Icons .
    1)  GreenLeaf
    2)  YellowLeaf
    3)  Redleaf
    4)  Rat

So ...you need to just copy and paste Controller and Visualforce page code in your org and you can customize as per your need.

Controller Code :-


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
public class DemoLeafletClass {
    
    public list<pinpoint__c> pinList{get;set;}
    
    public String FinalStr{get;set;}
    public String HunRec{get;set;}
    
    String[] stringListmiddle = new String[0];
    
    public DemoLeafletClass (){
        
        
        pinlist = [select id,name,latitude__c,longitude__c,Pop_up__c,Range__c from pinpoint__c ];
        
        string middle ;
        
        for(pinpoint__c p:pinlist){
                        
            middle = System.Label.latlongname;
            middle = middle .replace('longitude', string.valueof(p.longitude__c));
            middle = middle .replace('latitude', String.valueof(p.latitude__c));
            middle = middle .replace('streetName', p.name);
            
            middle = middle .replace('RangeValue',string.valueof( p.range__c));            
            stringListmiddle.add(middle);            
        }
        
        FinalStr = String.join(stringListmiddle, ' ');        
        FinalStr = System.Label.FeatureCollection+FinalStr +System.Label.last;                
    }                
}

Visualforce Page Code :-


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<apex:page controller="DemoLeafletClass" >
<apex:form style="width:900px">
<apex:pageblock >
<div align="center" draggable="false" >
        <apex:commandButton value="Reload"  onclick="load();" reRender="map"  styleClass="myClass"/>    
        &nbsp;&nbsp;&nbsp;&nbsp;
        <apex:commandButton value="Clear Marker"  onclick="clearmarker();" reRender="map" styleClass="myClass" />                 
   </div>
 </apex:pageblock>
  </apex:form>
<html>
<head>
  <title>A Leaflet map!</title>
 <title>A Leaflet map!</title>

  <link rel="stylesheet" type="text/css" href="{!URLFOR($Resource.leaflet, '/leaflet.css')}"/>  
  <link rel="stylesheet" type="text/css" href="{!URLFOR($Resource.MarkerCluster, 'markercluster/dist/MarkerCluster.css')}"/>  
  <link rel="stylesheet" type="text/css" href="{!URLFOR($Resource.MarkerCluster, 'src/MarkerClusterGroup.Refresh.js')}"/> 
  <link rel="stylesheet" type="text/css" href="{!URLFOR($Resource.MarkerCluster, 'markercluster/dist/MarkerCluster.Default.css')}"/> 

  <script type="text/javascript" src="{!URLFOR($Resource.leaflet, '/leaflet.js')}"></script>  
  <script type="text/javascript" src="{!URLFOR($Resource.MarkerCluster, 'markercluster/dist/leaflet.markercluster.js')}"></script>  
  <script type="text/javascript" src="{!URLFOR($Resource.jquery, '/jquery-2.1.1.min.js')}"></script>
  
  <style type="text/css">
.myClass{
padding: 10px;
color:white !important;
background:#00CC00 !important;

            
}
</style>
  <style>
    #map{ width: 900px; height: 600px; }
  </style>
</head>
<body>

  <div id="map"></div>

  <script>
  var rodents;
  var marker;
 
  // initialize the map
  var map = L.map('map').setView([42.35, -71.08], 13);
// load a tile layer
  L.tileLayer('http://tiles.mapc.org/basemap/{z}/{x}/{y}.png',
    {
      attribution: 'Tiles by <a href="http://mapc.org">MAPC</a>, Data by <a href="http://mass.gov/mgis">MassGIS</a>',
      maxZoom: 17,
      minZoom: 9
    }).addTo(map);
  
  function load(){        
      rodents = L.geoJson({!FinalStr});
      marker = map.addLayer(rodents);      
    }

function clearmarker(){
    rodents.clearLayers();
  }
  
  </script>
</body>
</html>

</apex:page>


Output Screen 1:-




Output Screen 2:- After Click on Reload Button



Output Screen 3:- After Click on Clear Marker Button


 To Make this post simpler I have just explained how to show and remove markers from map.
 In my next tutorials I will explain about
 1) PopUp on Markers.
 2) Showing our custom Image on popup.
 4) Showing our custom Image on popup and Making Marker cluster.
 5) Showing different popup based on different range value.
 6) Showing Legends on Map.
 7) Showing Image Legends on Map.


Monday, 17 April 2017

Salesforce Certified Platform Developer I – Spring ’17 Release Exam

Salesforce Certified Platform Developer I – Spring ’17 Release Exam
1 . Which feature enables creating, updating and deleting records in other Salesforce orgs?
A. Lightning-to-Lightning Connector
B. Apex Triggers for Writeable External Objects
C. Database.WriteableObject Interface
D. Salesforce Connect Cross-Org Adapter
Ans: D
2 . Which three types of content can shortcuts be created for using Favorites? 
Choose 3 answers
A. Chatter groups
B. Record home pages
C. Custom tabs
D. Dashboards
E. Global actions
Ans: A, B, D
3 . Which three actions can be taken from the Global Actions Menu? 
Choose 3 answers
A. Execute anonymous blocks of Apex code.
B. Launch a custom Visualforce Page.
C. Launch a custom Canvas App.
D. Post to a Chatter feed.
E. Launch a custom Lightning Component.
Ans: B, C, E
4 . A Platform Developer wants to reference an image included in the Salesforce Lightning Design System from a Visualforce page.
Which two references should be included in the page markup? 
Choose 2 answers
A. $SLDS
B. <force:slds>
C. <apex:slds>
D. $Asset
C, D
5 . Custom Lightning Record Pages can be assigned to which three items? 
Choose 3 answers
A. Record types
B. Apps
C. Profiles

D. Roles
E. Public groups
Ans: A, B, C
6 . Which component type will display the details of the parent Account from a custom Lightning record page for the Contact object?
A. Hierarchy component
B. Parent object component
C. Filter list component
D. Related record component
Ans: D
7 . Which two options are available to display detailed information about the status of an Apex batch job? 
Choose 2 answers
A. Elapsed time
B. Submitted by user
C. Submitted date
D. Heap size
Ans: A, C

Salesforce Certified Platform App Builder – Spring ´17 Release Exam

Salesforce Certified Platform App Builder – Spring ´17 Release Exam

Question 1: How can an App Builder determine whether the features and customizations made in an org are Lightning-ready ?

A. Implement the Salesforce Lightning Design System in a Sandbox
B. Use the Lightning Experience Readiness Toolkit in Workbench
C. Launch the Lightning Experience Readiness Check from All Setup
D. Download the Lightning Experience Audit Tool from AppExchange
Answer: C 

Question 2: How can an App Builder share Favorites with other Salesforce users ?

A. Favorites can´t be shared with other Users
B. Favorites Settings under My Personal Information
C. Sharing can only be performed by Users with System Administrator rights
D. Share link in Favorites drop-down menu
Answer: A

Questions 3: Which two of the following are supported actions for the Global Actions Menu ?

A. Launch a custom Lightning Component
B. Post to a Chatter Feed
C. Upload a new Chatter File
D. Launch a Custom Canvas App
Answer: A & D 

Question 4: What Lightning Experience feature allows Salesforce users to modify existing records without opening them ?

A. Inline editing in List Views
B. Global Actions
C. Editable Reports
D. The edit option in the Favorites menu
Answer: A 

Question 5: Which three options are available for assigning access to Lightning Pages using Lightning App Builder ?

A. The org default
B. App default
C. App, record type, profile
D. Profile and permission sets
E. Role and subordinates
Answer: A, B & C

Wednesday, 12 April 2017

Wrapper Class : Using InnerClass Constructor In Main Class Constructor



Wrapper Class:-


public class DeleteTeacherRecords
{
    public list<Teacher__c> studentRecds{get;set;}
    public list<TeacherInner> allTechRec {get;set;}
    
    public DeleteTeacherRecords(ApexPages.StandardController controller) {
    
        allTechRec = new list<TeacherInner>();
       
        //Fetching Teacher's Records
        studentRecds = [select id,name from Teacher__c];
        
        //Creating a list of Records to show in Visualforce page
        for(integer i =0;i<studentRecds.size();i++)
        {
           //Calling InnerClass constructor
             TeacherInner conObj = new TeacherInner(false,studentRecds[i]);
             allTechRec.add(conObj);
        }        
    }

    public pagereference deleteTearcherRecords()
    {    
        for(integer i=0;i<allTechRec.size();i++)
        {         
            if(allTechRec[i].checkbox == true)
            {           
                delete allTechRec[i].techObj;
            }
        }
      
        pagereference ref = new pagereference('/apex/DeleteRecUsingWrap');
        ref.setredirect(true);
        return ref;
    }
    //Inner Class
    public class TeacherInner
    {
        public boolean checkbox{get;set;}
        public Teacher__c techObj{get;set;}
        //This Inner class constructor is used in main classs constructor to show
        //Records in visualforce page
        public TeacherInner(boolean Mainclasscheckbox,Teacher__c 
                        MainclasstechObj)
        {
            checkbox = Mainclasscheckbox;
            techObj   = MainclasstechObj;
        }
    }
}


Visualforce Page :-


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
<apex:page standardController="Teacher__c" extensions="DeleteTeacherRecords">
  <apex:form >
      <apex:pageBlock >
        <apex:pageBlockTable value="{!allTechRec}" var="a">
             <apex:column headerValue="Select">
               <apex:inputCheckbox value="{!a.checkbox}"/>
            </apex:column>           
            <apex:column headerValue="Teacher Name">
               <apex:outputField value="{!a.techObj.name}"/>
            </apex:column>            
        </apex:pageBlockTable>
        <apex:pageBlockButtons >
        <apex:commandButton value="Delete Selected Records" action="{!deleteTearcherRecords}"/>
        </apex:pageBlockButtons>
      </apex:pageBlock>
  </apex:form> 
</apex:page>


Output Screenshot:


Wrapper Class : Delete and Update Selected Records Using Wrapper Class

In below example we will learn about how we can delete and Update selected records using wrapper Class.



Wrapper Class:



global Class Casecls{
    
    List<CaseclsInner> CaseInList = new List<CaseclsInner>();
    public Case CaseType{get;set;}
    
    global casecls(){
    CaseType = new Case();
    }
        
    global Class CaseclsInner{
        
        global Case CaseObj{get;set;}
        global Boolean checkboxObj{get;set;}
        
        global CaseclsInner(){
        }                
    }
    
    public List<CaseclsInner> getAllCaseRecords(){
                        
        for(Case c:[Select Id,CaseNumber,Type FROM Case]){
            CaseclsInner caseInobj = new CaseclsInner();
            caseInobj.CaseObj = c;
            CaseInList.add(caseInobj);            
        }        
        return CaseInList;        
    }
    
    public pagereference DeleteRecords(){
        
        List<Case> cList = new List<Case>();
        //Iterating through the list
        for(integer i=0;i<CaseInList.size();i++)
        {  
            if(CaseInList[i].checkboxObj == true)
            {
                //deleting student records based on lists index
                cList.add(CaseInList[i].CaseObj);
            }                        
        }
        
        delete cList;
            
        pagereference ref = new pagereference('/apex/CaseclsDelete');
        ref.setredirect(true);
        return ref;                
    }
    
    public pagereference ChangeType(){
        
        List<Case> cList = new List<Case>();
        //Iterating through the list
        for(integer i=0;i<CaseInList.size();i++)
        {  
            if(CaseInList[i].checkboxObj == true)
            {                
                CaseInList[i].CaseObj.Type = CaseType.type;                
                cList.add(CaseInList[i].CaseObj);
            }                        
        }
        
        update cList;
            
        pagereference ref = new pagereference('/apex/CaseclsDelete');
        ref.setredirect(true);
        return ref;                        
    }    
}


Visualforce Page:-



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
<apex:page Controller="Casecls">
    <apex:form >
        <apex:pageBlock >
            <apex:pageblockSection >
                <apex:commandButton action="{!DeleteRecords}" value="Delete Selected Records"/><br></br>
                <apex:commandButton value="Change Type Of Selected Records" action="{!Changetype}" reRender="theTable"/>
                <apex:inputField value="{!CaseType.type}"/>
            </apex:pageblockSection>
            <apex:pageblockTable value="{!AllCaseRecords}" var="v">
                <apex:column headerValue="Checkbox">
                <apex:inputCheckbox value="{!v.checkboxobj}"/>
                </apex:column>
                <apex:column value="{!v.CaseObj.CaseNumber}"/>
                <apex:column value="{!v.CaseObj.Type}"/>
            </apex:pageblockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Output :-


Wrapper Class: Showing Records in Same Column

In below example i have shown you how we can collect records from different Object in a single
List and shown them in Visualforce page.


We will be user Case and Lead Standard Object to perform this Task ,First i will show you
how we can collect records belongs to different Object in single list and show those records in Same column.


Wrapper Class:-


global class wrapDelete {        
    public wrapDelete (){}
    
    Global class wrapDeleteInner{        
        global Case CaseObj{get;set;}
        global Lead LeadObj{get;set;}
        
        global wrapDeleteInner(){}
        
        }
        
        global List<wrapDeleteInner> getDeleteList(){            
            List<wrapDeleteInner> wrap = new List<wrapDeleteInner>();
            
            for (Lead l:[Select id,name from Lead limit 5]){
                wrapDeleteInner wr = new wrapDeleteInner();
                wr.LeadObj = l;
                wrap.add(wr);                               
            } 
            
            for (Case C:[Select id,CaseNumber from Case limit 5]){
                wrapDeleteInner wr = new wrapDeleteInner();
                wr.CaseObj = C;
                wrap.add(wr);                               
            }            
            return wrap;                                
        }        
    
}

Visualforce Page:-


<apex:page Controller="wrapDelete">       
     <apex:dataTable value="{!DeleteList}" var="item">
          <apex:column headerValue="All Records(Lead and Case)">            
          <apex:outputField value="{!item.LeadObj.name}" />         
             <apex:outputField value="{!item.CaseObj.CaseNumber}" />
          </apex:column>
        </apex:dataTable>
</apex:page>

Output :-


Wrapper Class : Showing Records in separate Column

In below example i have shown you how we can collect records from different Object in a single
List and shown them in Visualforce page.


We will be user Case and Lead Standard Object to perform this Task ,First i will show you
how we can collect records belongs to different Object in single list and shown them in
Different Column(We can also show those records in Same column that i will explain in separate post)



Wrapper Class:-



global class wrapDelete {        
    public wrapDelete (){}
    
    Global class wrapDeleteInner{        
        global Case CaseObj{get;set;}
        global Lead LeadObj{get;set;}
        
        global wrapDeleteInner(){}
        
        }
        
        global List<wrapDeleteInner> getDeleteList(){            
            List<wrapDeleteInner> wrap = new List<wrapDeleteInner>();
            
            for (Lead l:[Select id,name from Lead limit 5]){
                wrapDeleteInner wr = new wrapDeleteInner();
                wr.LeadObj = l;
                wrap.add(wr);                               
            } 
            
            for (Case C:[Select id,CaseNumber from Case limit 5]){
                wrapDeleteInner wr = new wrapDeleteInner();
                wr.CaseObj = C;
                wrap.add(wr);                               
            }            
            return wrap;                                
        }        
    
}


Visualforce Page:-


<apex:page Controller="wrapDelete">
    <apex:pageBlock title="Lead and Case Table">
        <apex:pageblockTable value="{!DeleteList}" var="item">
            <apex:column value="{!item.LeadObj.name}"/>            
            <apex:column value="{!item.CaseObj.CaseNumber}"/>           
        </apex:PageblockTable>                       
    </apex:pageBlock>
</apex:page>

Output :-



Delete Child Records When Parent Got Deleted in Lookup Relationship


For this We have taken Two object Teacher(Parent Object) and Employee(Chile Object)

Teacher Structure (PARENT):-



Employee Structure(CHILD) :-



Trigger on Parent Object(Teacher) :-



trigger onParentObjectDelete on Teacher__c (before delete){    
    list<ID> Teacherlist = new list<ID> ();
    
    if(Trigger.isbefore && Trigger.isDelete)
    {
        For(Teacher__c T:Trigger.old)
        {
            Teacherlist.add(T.ID);    
        }
    }
    
    List<Employee__c> EmpList= [Select ID, Teacher_lookup__c from Employee__c 
                                            where Teacher_lookup__c IN :Teacherlist ];           
    delete EmpList;    
}