【发布时间】:2020-08-28 16:02:26
【问题描述】:
我正在尝试遍历包装类中的记录列表并将它们显示在 Visualforce 页面上。自定义对象称为 Campaign_Products__c,包装类旨在显示用户是否已选择产品添加到“购物车”。
Apex 控制器代码(已删除无关位):
public with sharing class CONTROLLER_Store {
...
public List<productOption> cpList { get; set; }
public class productOption {
public Campaign_Product__c product;
public Boolean inCart;
public Integer quantity;
}
...
public CONTROLLER_Store(){
...
List<Campaign> cmpList = getCampaignWithProducts(CampaignId,'');
// method above calls a campaign with a related list of Campaign Product records
if(cmpList.size() > 0){
cmp = cmpList[0];
cpList = new List<productOption>();
for(Campaign_Product__c pro : cmp.Campaign_Products__r){
productOption option = new productOption();
option.product = pro;
option.inCart = false;
option.quantity = 0;
cpList.add(option);
}
} else {
cmp = new Campaign();
CampaignId = null;
cpList = new List<productOption>();
}
....
}
Visualforce 页面(已删除无关位)
<apex:page controller="CONTROLLER_Store" >
<apex:repeat value="{! cpList }" var="option">
{!option.product.Product__r.Name}
<apex:inputCheckbox value="{! option.inCart }"/>
</apex:repeat>
</apex:page>
我在尝试保存 visualforce 页面时收到此错误:
Unknown property 'CONTROLLER_Store.productOption.product'
【问题讨论】:
标签: salesforce apex visualforce