function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
adi salesforceadi salesforce 

How to write vf page for this apex class.

Map<String, map<String, Integer>> ratingVsRecordCountMapOfmap = new Map<String, map<String, Integer>>();
List<Task> lstAggResult = [Select Priority, Status From Task Where Priority != Null AND Status != Null];
if(!lstAggResult.isEmpty()) {
 for(Task objTest : lstAggResult) {
       if(ratingVsRecordCountMapOfmap.containsKey(objTest.Priority)) {
            Map<String, Integer> innermap = ratingVsRecordCountMapOfmap.get(objTest.Priority);
            //if(!innermap.isEmpty()) {
                if(innermap.containsKey(objTest.Status)) {
                   Integer count = innermap.get(objTest.Status) + 1;
                  innermap.put(objTest.Status, count);
               }
               else {
                   innermap.put(objTest.Status, 1);
               }
               ratingVsRecordCountMapOfmap.put(objTest.Priority, innermap);
           //}
        }
       else {
            Map<String, Integer> innermap = new Map<String, Integer>();
            innermap.put(objTest.Status, 1);
            ratingVsRecordCountMapOfmap.put(objTest.Priority, innermap);
       }
    }
}
system.debug('---> ' + ratingVsRecordCountMapOfmap);
Steven NsubugaSteven Nsubuga
Here is something for you to modify further if you wish.
Controller
public class TasksViewer {
	
	public List<String> getTaskStats() {
        
        List<String> taskStats = new List<String>();
		Map<String, map<String, Integer>> ratingVsRecordCountMapOfmap = new Map<String, map<String, Integer>>();

		List<Task> lstAggResult = [Select Priority, Status From Task Where Priority != Null AND Status != Null];

		if(!lstAggResult.isEmpty()) {
		 for(Task objTest : lstAggResult) {
			   if(ratingVsRecordCountMapOfmap.containsKey(objTest.Priority)) {
					Map<String, Integer> innermap = ratingVsRecordCountMapOfmap.get(objTest.Priority);
					//if(!innermap.isEmpty()) {
						if(innermap.containsKey(objTest.Status)) {
						   Integer count = innermap.get(objTest.Status) + 1;
						  innermap.put(objTest.Status, count);
					   }
					   else {
						   innermap.put(objTest.Status, 1);
					   }
					   ratingVsRecordCountMapOfmap.put(objTest.Priority, innermap);
				   //}
				}
			   else {
					Map<String, Integer> innermap = new Map<String, Integer>();
					innermap.put(objTest.Status, 1);
					ratingVsRecordCountMapOfmap.put(objTest.Priority, innermap);
			   }
			}
		}
        for (String priority : ratingVsRecordCountMapOfmap.keyset()) {
            taskStats.add(priority + ': ' +ratingVsRecordCountMapOfmap.get(priority));
        }
        return taskStats;
	}
    
}

VF page
<apex:page controller="TasksViewer">
    <apex:pageBlock title="Tasks Stats">
        <apex:pageBlockTable value="{!TaskStats}" var="taskStat">
            <apex:column title="stats" value="{!taskStat}" />
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>

 
adi salesforceadi salesforce
Hi
Thankyou responding the controller is for displaying task status priority and no.of records assosiated with both fields .

                     not started        inprogress
High                 5                      2
Normal             4                     6


like this I want to display. so could you  write vfpage code for above apex controller.