如何解决使用控制器类中的地图在 vf 页面上显示记录
嗨,我有一个名为 Accountserviceagent__C 的对象,其中有两个与帐户和联系人对象相关的查找字段。 我创建了一个嵌套映射来显示 1 id(联系人 id)、第二个 ID(帐户 id)和 Accountserviceagent__C 记录。 我需要在我的 vf 页面中显示这些值。 我尝试了以下代码,但我的 vf 页面中没有返回任何内容。有人可以帮我解决问题吗? 类:
public class NestedMapexample {
public Map<Id,Map< Id,List<Account_servicing__c>>> Accountmapping{get;set;}
// 1st id=contact ids 2nd id=acccount ids listof records//
public NestedMapexample(){
Map<Id,List<Account_servicing__c>>> Accountmapping= new Map<Id,List<Account_servicing__c>>>();
Map< Id,List<Account_servicing__c>> ServiceRecords = new Map<Id,List<Account_servicing__c>>();
for(Account_servicing__c s:[select id,Accountname__r.id,Name,Contactname__r.id from Account_servicing__c ]){
if(ServiceRecords.containsKey(s.Accountname__r.Id)){
ServiceRecords.get(s.Accountname__r.Id).add(s);
}
else{
ServiceRecords.put(s.Accountname__r.Id,new List<Account_servicing__c>{s});
}
Accountmapping.put(s.Contactname__r.Id,ServiceRecords);
}system.debug(''+ServiceRecords);
}
}
vf 页面:
<apex:page controller="NestedMapexample">
<apex:form >
<apex:pageblock >
<apex:pageblockTable value="{!Accountmapping}" var="a">
<apex:column value="{!Accountmapping[a].Contactname__r.id}"/>
<apex:column value="{!Accountmapping[a].Accountname__r.id}"/>
<apex:column value="{!Accountmapping[a].Accountname__r.Account_servicing__c.name}"}">
</apex:pageblockTable>
</apex:pageblock>
</apex:form>
</apex:page>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。