我正在尝试迭代包装器类中的记录列表,并在Visualforce页面上显示它们。自定义对象称为Campaign_Products__c,包装类的目的是显示用户是否选择了要添加到“购物车”的产品。
先端控制器代码(移除无关位):
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'发布于 2020-08-28 17:50:02
您也需要使包装器中的属性对VF可见。有点像
public class productOption {
public Campaign_Product__c product {get; private set};
public Boolean inCart {get; set};
public Integer quantity {get; set};
}(假设产品应该在VF中只读)。您需要这些访问修饰符或完整的getter/setter方法。
https://stackoverflow.com/questions/63637292
复制相似问题