APEX CLASS:
public class TestMapController{
public map<string,integer> data {get;set;}
public TestMapController(){
data = new map<string,integer>();
for(Account acc: [Select Id, Name, (Select Id, Name, Email from Contacts), Phone from Account]){
integer count = data.get(acc.name);
if(count != null)
count++;
else
count = 1;
data.put(acc.name, count);
}
}
}
public map<string,integer> data {get;set;}
public TestMapController(){
data = new map<string,integer>();
for(Account acc: [Select Id, Name, (Select Id, Name, Email from Contacts), Phone from Account]){
integer count = data.get(acc.name);
if(count != null)
count++;
else
count = 1;
data.put(acc.name, count);
}
}
}
VisualForce Page:
<apex:page controller="TestMapController">
<apex:pageblock title="Map Usage On VF">
<apex:pageBlockTable value="{!data}" var="d">
<apex:column headerValue="Account Name">
{!d}
</apex:column>
<apex:column headerValue="Duplicate Count">
{!data[d]}
</apex:column>
</apex:pageBlockTable>
</apex:pageblock>
</apex:page>
<apex:pageblock title="Map Usage On VF">
<apex:pageBlockTable value="{!data}" var="d">
<apex:column headerValue="Account Name">
{!d}
</apex:column>
<apex:column headerValue="Duplicate Count">
{!data[d]}
</apex:column>
</apex:pageBlockTable>
</apex:pageblock>
</apex:page>
No comments:
Post a Comment