public class Checkbox_Class {
public list<contactwrapper> contList {set;get;}
public list<contact> contacts {set;get;}
public list<contactwrapper> SelectedcondList{get;set;}
public list<contact> contactlist{set;get;}
public Checkbox_Class(){
contList=new list<contactwrapper>();
contacts=[select id,name,lastName,email from contact];
for(contact c:contacts){
contList.add(new contactwrapper(c));
}
}
public PageReference Addconatct()
{
PageReference pageRef= new PageReference('/apex/Checkbox_Class2');
pageRef.setredirect(false);
return pageRef;
}
public PageReference cancell()
{
PageReference pageRef= new PageReference('/003?fcf=00B1U00000B6Chn');
return pageRef;
}
public list<contactwrapper> getSelectedContacts()
{
SelectedcondList = new list<contactwrapper>();
contactlist=new list<contact>();
for(contactwrapper Con:contList)
{
if(Con.flag==true)
{
SelectedcondList.add(Con);
contactlist.add(con.con);
}
}
return SelectedcondList;
}
public class contactwrapper{
public contact con {set;get;}
public boolean flag {set;get;}
public contactwrapper(contact c){
con=c;
flag=false;
}
}
public void sentmail()
{
EmailTemplate templateId = [Select id from EmailTemplate where name = 'contactEmail'];
List<Messaging.SingleEmailMessage> allmsg = new List<Messaging.SingleEmailMessage>();
for(contact con : contactlist)
{
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setTemplateID(templateId.Id);
mail.setTargetObjectId(con.id);
mail.setSaveAsActivity(false);
allmsg.add(mail);
}
Messaging.sendEmail(allmsg,false);
}
}
-------------------------------------------------------------------------------------------------------------------
<apex:page controller="Checkbox_Class" Tabstyle="contact">
<script type="text/javascript">
function selectAllCheckboxes(obj,receivedInputID){
var inputCheckBox = document.getElementsByTagName("input");
for(var i=0; i<inputCheckBox.length; i++){
if(inputCheckBox[i].id.indexOf(receivedInputID)!=-1){
inputCheckBox[i].checked = obj.checked;
}
}
}
</script>
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value=" next" action="{!Addconatct}" />
<apex:commandButton value=" cancel" action="{!cancell}" />
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!contList}" var="c" id="table" title="All Accounts">
<apex:column >
<apex:facet name="header">
<apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/>
</apex:facet>
<apex:inputCheckbox value="{!c.flag}" id="inputId"/>
</apex:column>
<apex:column value="{!c.con.Name}" />
<apex:column value="{!c.con.email}" />
<apex:column value="{!c.con.lastName}" />
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
public list<contactwrapper> contList {set;get;}
public list<contact> contacts {set;get;}
public list<contactwrapper> SelectedcondList{get;set;}
public list<contact> contactlist{set;get;}
public Checkbox_Class(){
contList=new list<contactwrapper>();
contacts=[select id,name,lastName,email from contact];
for(contact c:contacts){
contList.add(new contactwrapper(c));
}
}
public PageReference Addconatct()
{
PageReference pageRef= new PageReference('/apex/Checkbox_Class2');
pageRef.setredirect(false);
return pageRef;
}
public PageReference cancell()
{
PageReference pageRef= new PageReference('/003?fcf=00B1U00000B6Chn');
return pageRef;
}
public list<contactwrapper> getSelectedContacts()
{
SelectedcondList = new list<contactwrapper>();
contactlist=new list<contact>();
for(contactwrapper Con:contList)
{
if(Con.flag==true)
{
SelectedcondList.add(Con);
contactlist.add(con.con);
}
}
return SelectedcondList;
}
public class contactwrapper{
public contact con {set;get;}
public boolean flag {set;get;}
public contactwrapper(contact c){
con=c;
flag=false;
}
}
public void sentmail()
{
EmailTemplate templateId = [Select id from EmailTemplate where name = 'contactEmail'];
List<Messaging.SingleEmailMessage> allmsg = new List<Messaging.SingleEmailMessage>();
for(contact con : contactlist)
{
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setTemplateID(templateId.Id);
mail.setTargetObjectId(con.id);
mail.setSaveAsActivity(false);
allmsg.add(mail);
}
Messaging.sendEmail(allmsg,false);
}
}
-------------------------------------------------------------------------------------------------------------------
<apex:page controller="Checkbox_Class" Tabstyle="contact">
<script type="text/javascript">
function selectAllCheckboxes(obj,receivedInputID){
var inputCheckBox = document.getElementsByTagName("input");
for(var i=0; i<inputCheckBox.length; i++){
if(inputCheckBox[i].id.indexOf(receivedInputID)!=-1){
inputCheckBox[i].checked = obj.checked;
}
}
}
</script>
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value=" next" action="{!Addconatct}" />
<apex:commandButton value=" cancel" action="{!cancell}" />
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!contList}" var="c" id="table" title="All Accounts">
<apex:column >
<apex:facet name="header">
<apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/>
</apex:facet>
<apex:inputCheckbox value="{!c.flag}" id="inputId"/>
</apex:column>
<apex:column value="{!c.con.Name}" />
<apex:column value="{!c.con.email}" />
<apex:column value="{!c.con.lastName}" />
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
No comments:
Post a Comment