I am trying to iterate over and display a Map<String,List<string>>
in a visualforce page. I understand that I probably need to switch to a inner / wrapper class. But first, I want to make sure that the map is populating properly, as what I'm seeing when passing the maps values to system.debug seems strange to me, so want to validate.
The keyset is clearly populating correctly, and is displaying fine on the visualforce page. Its the values which look, to my eyes, like the previous lists are being blanked out when a new one is added.
I'll insert the screenshot of the debug log first, and then some of the relevant code
Screenshot of debug log - see how the previous set of values do not appear in the next step of the log
Code Snippet:
map<string,list<string>> ApproverGroupMap = new map<string,list<string>>();
private void populateLists(){
FOR (group g : grouplist){
integer groupsize = 0;
list<string> activeGroupMembers = new list<string>();
FOR(groupmember gm : g.groupMembers){
IF(activeUserIds.contains(gm.UserorGroupId)){
groupsize ++;
string un = umap.get(gm.UserorGroupId).name;
activeGroupMembers.add(un);
}
}
system.debug('activegroupmembers.size - ' + activegroupmembers.size());
approverGroupMap.put(g.Name,activeGroupMembers);
system.debug('approvergroupmap keyset = ' + approverGroupMap.keySet());
system.debug('approvergroupmap values = ' + approverGroupMap.values());
IF(groupsize == 0){
emptygrouplist.add(g.Developername);
}
activeGroupMembers.clear();
}