apex - 无法从组件控制器获取值到 visualforce 自定义组件
问题描述
我必须在 visualforce 组件中显示客户详细信息。我能够从包装类获取值到 vf 组件控制器,但无法使用 apex:repeat 在 VF 组件中显示值。我正在使用 Map 在组件中显示值,因为一个客户可能有 1 个或多个记录,因此我需要将客户 ID 显示为标题,在此标题下我需要显示此客户记录,然后是第二个客户等等。 ..
****VF Component****
<apex:component controller="CustSrchController">
<apex:attribute name="custExtId" type="String" description="passing customer external Id" assignTo="{!CustomerExtId}"/>
<apex:pageBlock title="Customer Details 4...">
<apex:repeat value="{!PackageMap1}" var="cust2">
<apex:outputText value="{!PackageMap1[cust2]}" />
<apex:pageBlockSection columns="3">
<apex:facet name="header"> Customer Id {!PackageMap1[cust2].custId}</apex:facet>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Card Number" for="custCC" />
<apex:outputText value="{!PackageMap1[cust2].custCC}" id="custCC" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Account Id" for="custAccID" />
<apex:outputText value="{!PackageMap1[cust2].custAccID}" id="custAccID" />
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:repeat>
</apex:pageBlock>
</apex:component>
****VF Component Controller****
public class CustSrchController {
public String CustomerExtId;
public void setCustomerExtId (String s) {
CustomerExtId = s.toUpperCase();
}
public String getCustomerExtId() {
return CustomerExtId;
}
public list<WrapperResponses.Customers> lstCustomer{get;set;}
public List<WrapperResponses.Customers> lstCustExtDetailsSearch{get;private set;}
List<String> custList = new List<String>();
public Map<string,WrapperResponses.Customers> custMap = new Map <string,WrapperResponses.Customers>();
public Map<string,List<String>> custMap1 = new Map <string,List<String>>();
public void CustomerDetails(){
//public void getCustomerDetails(){
WrapperResponses.CustInquiryResp cust = APIController.getCustomerInquiry('ABC',CustomerExtId,'PQR');
lstCustomer = cust.customers;
WrapperResponses.CustSearchResp custSearch = APIController.searchCustomers('LNAME','FNAME','M','1234','1234567890','A1','123456','abc@gmail.com');
lstCustExtDetailsSearch = custSearch.customers;
for (WrapperResponses.Customers custItem : lstCustomer) {
custList.add(custItem.custId);
custList.add(custItem.custCC);
custList.add(custItem.custAccID);
custMap.put(custItem.customerExternalIdentifier, custItem);
//custMap.put(custItem.customerExternalIdentifier, custList);
custMap1.put(custItem.customerExternalIdentifier, custList);
}
}
public Map<string,WrapperResponses.Customers> getPackageMap() {
return custMap;
}
public Map<string,List<String>> getPackageMap1() {
return custMap1;
}
}
****Wrapper Class****
public with sharing class WrapperResponses {
public WrapperResponses() {
}
//API Response for Customer Inquiry API
public class CustInquiryResp{
public List<Customers> customers;
}
// API Response for Customer Search API
public class CustSearchResp{
public List<Customers> customers;
}
//Dummy API to get Customer Response
public class Customers {
//these are from inquiry api
public String customerId{get;}
public String customerCC{get;}
public String customerAccId{get;}
}
}
解决方案
推荐阅读
- sql - SQL 3 表联合、连接、输入
- c# - 使用 MVVM 创建具有现有外部属性的 EF Core 实体
- python - 使用 subprocess.Popen 将输出重定向到文件
- python - 从列表中删除最大值和最小值而不复制列表
- c++ - 添加新库时未解决的外部符号错误 C++
- android - 我们可以访问双摄像头智能手机中的两个摄像头传感器吗
- apache-kafka - 使用 ksqldb-server 在 kafka 中创建表
- go - 带有两个对象的结构到 JSON
- mongodb - Strapi (CMS) - 如何配置以使用多个数据库/集合
- laravel - Laravel 8 无法正常工作,错误“file_put_contents”