Apex Class:
public class Checkbox_Class {
List
List
public List
for(Account a: [select Id, Name, AccountNumber, Phone from Account limit 5])
accountList.add(new accountwrapper(a));
return accountList;
}
public PageReference getSelected() {
selectedAccounts.clear();
for(accountwrapper accwrapper: accountList)
if(accwrapper.selected == true)
selectedAccounts.add(accwrapper.acc);
return null;
}
public List
if(selectedAccounts.size()>0)
return selectedAccounts;
else
return null;
}
public class accountwrapper {
public Account acc{get; set;}
public Boolean selected {get; set;}
public accountwrapper(Account a)
{
acc = a;
selected = false;
}
}
}
VisualForce Page:
Demo : https://sfdevforce-developer-edition.na12.force.com/vfCheckbox