Scenario:
I want to retrieve few records from a particular object and to display them in a Page Block Table along with checkbox for each row in a Table .Now,I will select few records from that table and I will display them in below PageBlock Table with the help of Action Support Function.
VisualForce Page:
<apex:page controller="wrapperClassController">
<apex:form >
<apex:pageBlock >
<!-- In our table we are displaying the cContact records -->
<apex:pageBlockTable value="{!contacts}" var="c" >
<apex:column >
<apex:actionSupport event="onclick" action="{!processSelected}" reRender="pbt2">
<!-- This is our selected Boolean property in our wrapper class -->
<apex:inputCheckbox value="{!c.selected}" />
</apex:actionSupport>
</apex:column>
<!-- This is how we access the contact values within our cContact container/wrapper -->
<apex:column value="{!c.con.Name}" />
<apex:column value="{!c.con.Email}" />
<apex:column value="{!c.con.Phone}" />
</apex:pageBlockTable>
</apex:pageBlock>
<apex:pageBlock id="test">
<apex:outputPanel id="pbt2">
Total No of Selected Records :<apex:outputText value="{!value }"/>
<apex:pageBlockTable value="{!SelectedContacts}" var="c" >
<apex:column value="{!c.Name}" />
<apex:column value="{!c.Email}" />
<apex:column value="{!c.Phone}" />
</apex:pageBlockTable>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller Class:
public class wrapperClassController
{
//Our collection of the class/wrapper objects cContact
public List<cContact> contactList {get; set;}
public List<Contact> selectedContacts{get;set;}
public Integer value {get;set;}
public List<cContact> getContacts()
{
if(contactList == null) {
contactList = new List<cContact>();
for(Contact c : [select Id, Name, Email, Phone from Contact limit 10])
{
//As each contact is processed we create a new cContact object and add it to the contactList
contactList.add(new cContact(c));
}
}
return contactList;
}
public PageReference processSelected()
{
//We create a new list of Contacts that we be populated only with Contacts if they are selected
selectedContacts = new List<Contact>();
//We will cycle through our list of cContacts and will check to see if the selected
//property is set to true, if it is we add the Contact to the selectedContacts list
for(cContact cCon : getContacts())
{
if(cCon.selected == true)
{
selectedContacts.add(cCon.con);
}
}
value = selectedContacts.size();
System.debug('printing listcontc'+selectedContacts.size());
// Now we have our list of selected contacts and can perform any type of logic we want,
// sending emails, updating a field on the Contact, etc
return null;
}
public List<Contact> getSelectedContacts()
{
System.debug('printing listcontc inside get'+selectedContacts.size());
if(selectedContacts.size()>0)
return selectedContacts;
else return null;
}
//This is our wrapper/container class. A container class is a class,a data structure,or an
//abstract data type whose instances are collections of other objects. In this example a
//wrapper class contains both the standard salesforce object Contact and a Boolean value
public class cContact
{
public Contact con {get; set;}
public Boolean selected {get; set;}
//This is the contructor method. When we create a new cContact object we pass a Contact
//that is set to the con property. We also set the selected value to false
public cContact(Contact c)
{
con = c;
selected = false;
}
}
}
ScreenShot:
I want to retrieve few records from a particular object and to display them in a Page Block Table along with checkbox for each row in a Table .Now,I will select few records from that table and I will display them in below PageBlock Table with the help of Action Support Function.
VisualForce Page:
<apex:page controller="wrapperClassController">
<apex:form >
<apex:pageBlock >
<!-- In our table we are displaying the cContact records -->
<apex:pageBlockTable value="{!contacts}" var="c" >
<apex:column >
<apex:actionSupport event="onclick" action="{!processSelected}" reRender="pbt2">
<!-- This is our selected Boolean property in our wrapper class -->
<apex:inputCheckbox value="{!c.selected}" />
</apex:actionSupport>
</apex:column>
<!-- This is how we access the contact values within our cContact container/wrapper -->
<apex:column value="{!c.con.Name}" />
<apex:column value="{!c.con.Email}" />
<apex:column value="{!c.con.Phone}" />
</apex:pageBlockTable>
</apex:pageBlock>
<apex:pageBlock id="test">
<apex:outputPanel id="pbt2">
Total No of Selected Records :<apex:outputText value="{!value }"/>
<apex:pageBlockTable value="{!SelectedContacts}" var="c" >
<apex:column value="{!c.Name}" />
<apex:column value="{!c.Email}" />
<apex:column value="{!c.Phone}" />
</apex:pageBlockTable>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller Class:
public class wrapperClassController
{
//Our collection of the class/wrapper objects cContact
public List<cContact> contactList {get; set;}
public List<Contact> selectedContacts{get;set;}
public Integer value {get;set;}
public List<cContact> getContacts()
{
if(contactList == null) {
contactList = new List<cContact>();
for(Contact c : [select Id, Name, Email, Phone from Contact limit 10])
{
//As each contact is processed we create a new cContact object and add it to the contactList
contactList.add(new cContact(c));
}
}
return contactList;
}
public PageReference processSelected()
{
//We create a new list of Contacts that we be populated only with Contacts if they are selected
selectedContacts = new List<Contact>();
//We will cycle through our list of cContacts and will check to see if the selected
//property is set to true, if it is we add the Contact to the selectedContacts list
for(cContact cCon : getContacts())
{
if(cCon.selected == true)
{
selectedContacts.add(cCon.con);
}
}
value = selectedContacts.size();
System.debug('printing listcontc'+selectedContacts.size());
// Now we have our list of selected contacts and can perform any type of logic we want,
// sending emails, updating a field on the Contact, etc
return null;
}
public List<Contact> getSelectedContacts()
{
System.debug('printing listcontc inside get'+selectedContacts.size());
if(selectedContacts.size()>0)
return selectedContacts;
else return null;
}
//This is our wrapper/container class. A container class is a class,a data structure,or an
//abstract data type whose instances are collections of other objects. In this example a
//wrapper class contains both the standard salesforce object Contact and a Boolean value
public class cContact
{
public Contact con {get; set;}
public Boolean selected {get; set;}
//This is the contructor method. When we create a new cContact object we pass a Contact
//that is set to the con property. We also set the selected value to false
public cContact(Contact c)
{
con = c;
selected = false;
}
}
}
ScreenShot:
51F04FE0
ReplyDeletekonya esçort numaraları
ankara rus esçort
esçort bayan düzce
esçort ağrı
osmaniye esçort
atakum esçort
esçort bayan ardahan
batıkent esçort
tunceli esçort
ReplyDeleteDer Antrag für den Bildungsgutschein im Bereich cybersecurity weiterbildung ist ein klarer Schritt, der gut vorbereitet sein sollte. Viele Teilnehmer unterschätzen die Bedeutung einer genauen Dokumentation ihrer beruflichen Qualifikationen. Das Bundesamt für Wirtschaft und Ausfuhrkontrolle stellt auf seiner Webseite detaillierte Anleitungen bereit, um den Prozess zu erleichtern. Es ist ratsam, alle relevanten Nachweise wie Arbeitszeugnisse oder Weiterbildungszertifikate griffbereit zu haben. Wer sich unsicher fühlt, kann sich an lokale Beratungsstellen wenden, die Unterstützung beim Antrag bieten. Eine wichtige Ressource ist auch https://csvisor.de/ mit Tipps zur Auswahl der passenden cybersecurity weiterbildung und zum Ablauf des Verfahrens. Die Bearbeitungszeit variiert meist zwischen zwei und vier Wochen, daher lohnt es sich frühzeitig alles vorzubereiten. Mit einem gut durchdachten Antrag erhöht man die Chance auf eine erfolgreiche Förderung erheblich.