Wrapper Class vs Helper Class vs Controller Class
bhanukarkra
Posted on May 26, 2021
Wrapper Class: To wrap the Data types to make a single object which can be assessable easily in other classes.
Controller Class Controller class contains public methods called Action methods. Each method has a one-to-one link with a possible user action, ranging from the click of a button to another trigger. The controller class methods process input data, execute application logic and determine view.
public class WrapNitesh {
//CONTROLLER CLASS
public list<wrapaccount> wrapaccountList { get; set; }
public list<account> selectedAccounts{get;set;}
public WrapNitesh (){
//if(wrapaccountList ==null){
wrapaccountList =new list<wrapaccount>();
for(account a:[select id,name,billingcity,phone from account limit 10]){
wrapaccountlist.add(new wrapaccount(a));
}
// }
}
//### SELECTED ACCOUNT SHOWN BY THIS METHOD
public void ProcessSelected(){
selectedAccounts=new list<account>();
for(wrapaccount wrapobj:wrapaccountlist){
if(wrapobj.isSelected==true){
selectedAccounts.add(wrapobj.accn);
}
}
}
//##THIS IS WRAPPER CLASS
// account and checkbox taken in wrapper class
public class wrapaccount{
public account accn{get;set;}
public boolean isSelected{get;set;}
public wrapaccount(account a){
accn=a;
isselected=false;
}
}
}
Helper Class helper class is used to assist in providing some functionality, which isn't the main goal of the application or class in which it is used
function linesOf($mls) {
return preg_split('/\s*\n\s*/',trim($mls));
}
💖 💪 🙅 🚩
bhanukarkra
Posted on May 26, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.