在 Vf 页面中使用类列表时未知属性

发布于 2024-12-07 12:29:41 字数 2843 浏览 3 评论 0原文

我有一个类,

public with sharing class CAccountRep {
string sageAccountNo {get;set;}
string clientName {get;set;}
string name {get;set;}
integer noofdays {get;set;}
string billableUnits {get;set;}
decimal dailyChargeRate {get;set;}
string nominalCode {get;set;}
string practice {get;set;}
string taxFlag {get;set;}
string ProjectId {get;set;}
string PONumber {get;set;}

public CAccountRep(String CrSageAc,String CrClientN,string CrName,integer Crnoofdays,string crbillableunits,decimal CrDecimalChargeRate,string crNominalCode,string CrPractice, String CrTaxFlag,String CrProjectId, String CrPONumber)
{
    sageAccountNo=CrSageAc;
    clientName=CrClientN;
    name=CrName;
    noofdays=Crnoofdays;
    billableUnits=crbillableunits;
    dailyChargeRate=CrDecimalChargeRate;
    nominalCode=crNominalCode;
    practice=CrPractice;
    taxFlag=CrTaxFlag;
    ProjectId=CrProjectId;
    PONumber=CrPONumber;

}

    }

我正在创建该类的一个对象,并将参数传递到该类中。

   public List<CAccountRep> AR { get;set; }

   public list<CAccountRep> getAR()
   {   
    if(AR!= null)
        return AR ;
    else return null;
   }

   Using the follwing code to create the object of the class

     CAccountRep CRep=new CAccountRep(projectList[0].Sage_Account_Number__c,projectList[0].Client_Name__c, Cname,enoOfBillableDays,projectList[0].BillableUnits__c,AssConlist[0].Daily_Charge_Rate_of_Consultant__c,AssConlist[0].Nominal_Code__c,projectList[0].C85_Practice__c,projectList[0].Tax_Flag__c,projectList[0].Project_ID__c,projectList[0].PO_Number__c);

     AR.add(CRep);

在我的 VF 页面中,我试图显示列表 AR 的内容。

但我在保存 VF 页面时收到错误 Unknown Propery CAccountRep.ProjectId 。

<table id="tableRep">
   <apex:repeat id="tc" value="{!AR}" var="TCrep">
   <tr>

   <td>{!TCrep.ProjectId}</td>
   </tr>
   </apex:repeat>
   </table>

如果我只给出 {!TCrep} 我可以得到这样的输出

CAccountRep:[PONumber=null, ProjectId=C85_JPMC1 _A-0083, billableUnits=null, clientName=001A000000YJFhdIAH, dailyChargeRate=null, name=Change Order 10002011-09-05 to 2011-10-10 : 0 null, nominalCode=null, noofdays=0, practice=Administration, sageAccountNo=null, taxFlag=null]
CAccountRep:[PONumber=null, ProjectId=C85_BBCWW _A-0084, billableUnits=null, clientName=001A000000cwgIlIAI, dailyChargeRate=null, name=Secure Desktop v012011-09-05 to 2011-10-10 : 0 null, nominalCode=null, noofdays=0, practice=null, sageAccountNo=null, taxFlag=null]
CAccountRep:[PONumber=null, ProjectId=C85_JPMC1 _A-0083, billableUnits=null, clientName=001A000000YJFhdIAH, dailyChargeRate=null, name=Change Order 10002011-09-05 to 2011-10-10 : 0 null, nominalCode=null, noofdays=0, practice=Administration, sageAccountNo=null, taxFlag=null]

关于如何让它正确显示有什么想法吗?

i have a class

public with sharing class CAccountRep {
string sageAccountNo {get;set;}
string clientName {get;set;}
string name {get;set;}
integer noofdays {get;set;}
string billableUnits {get;set;}
decimal dailyChargeRate {get;set;}
string nominalCode {get;set;}
string practice {get;set;}
string taxFlag {get;set;}
string ProjectId {get;set;}
string PONumber {get;set;}

public CAccountRep(String CrSageAc,String CrClientN,string CrName,integer Crnoofdays,string crbillableunits,decimal CrDecimalChargeRate,string crNominalCode,string CrPractice, String CrTaxFlag,String CrProjectId, String CrPONumber)
{
    sageAccountNo=CrSageAc;
    clientName=CrClientN;
    name=CrName;
    noofdays=Crnoofdays;
    billableUnits=crbillableunits;
    dailyChargeRate=CrDecimalChargeRate;
    nominalCode=crNominalCode;
    practice=CrPractice;
    taxFlag=CrTaxFlag;
    ProjectId=CrProjectId;
    PONumber=CrPONumber;

}

    }

Iam creating a object of this class and passing out the parameters into this class

   public List<CAccountRep> AR { get;set; }

   public list<CAccountRep> getAR()
   {   
    if(AR!= null)
        return AR ;
    else return null;
   }

   Using the follwing code to create the object of the class

     CAccountRep CRep=new CAccountRep(projectList[0].Sage_Account_Number__c,projectList[0].Client_Name__c, Cname,enoOfBillableDays,projectList[0].BillableUnits__c,AssConlist[0].Daily_Charge_Rate_of_Consultant__c,AssConlist[0].Nominal_Code__c,projectList[0].C85_Practice__c,projectList[0].Tax_Flag__c,projectList[0].Project_ID__c,projectList[0].PO_Number__c);

     AR.add(CRep);

In my VF page i am trying to display the contents of the list AR.

But i get an error Unknown Propery CAccountRep.ProjectId while saving the VF page.

<table id="tableRep">
   <apex:repeat id="tc" value="{!AR}" var="TCrep">
   <tr>

   <td>{!TCrep.ProjectId}</td>
   </tr>
   </apex:repeat>
   </table>

I can get the output like this if i just give {!TCrep}

CAccountRep:[PONumber=null, ProjectId=C85_JPMC1 _A-0083, billableUnits=null, clientName=001A000000YJFhdIAH, dailyChargeRate=null, name=Change Order 10002011-09-05 to 2011-10-10 : 0 null, nominalCode=null, noofdays=0, practice=Administration, sageAccountNo=null, taxFlag=null]
CAccountRep:[PONumber=null, ProjectId=C85_BBCWW _A-0084, billableUnits=null, clientName=001A000000cwgIlIAI, dailyChargeRate=null, name=Secure Desktop v012011-09-05 to 2011-10-10 : 0 null, nominalCode=null, noofdays=0, practice=null, sageAccountNo=null, taxFlag=null]
CAccountRep:[PONumber=null, ProjectId=C85_JPMC1 _A-0083, billableUnits=null, clientName=001A000000YJFhdIAH, dailyChargeRate=null, name=Change Order 10002011-09-05 to 2011-10-10 : 0 null, nominalCode=null, noofdays=0, practice=Administration, sageAccountNo=null, taxFlag=null]

Any ideas on how to get it display correctly?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

贱贱哒 2024-12-14 12:29:41

我认为编译器感到困惑,因为它认为您有 2 个公共 getter,即这两行:

public List<CAccountRep> AR { get;} // just removed set; for now

public list<CAccountRep> getAR()

当您在页面中使用以下语法时,将从 Visualforce 页面调用:

{!AR}

尝试这样做:

public List<CAccountRep> AR { get{
    return AR ; // if AR is null it returns null so the if statement was redundant

}set; }

并删除 getAR()方法。您还应该将您希望可见的类成员变量标记为公共,例如

public string ProjectId {get;set;}

I think the compiler is getting confused because you have 2 public getters in it's opinion i.e. both of these lines:

public List<CAccountRep> AR { get;} // just removed set; for now

public list<CAccountRep> getAR()

Would be called from a Visualforce page when you use the following syntax in the page:

{!AR}

Try doing this instead:

public List<CAccountRep> AR { get{
    return AR ; // if AR is null it returns null so the if statement was redundant

}set; }

And remove the getAR() method. You should also mark the class member variables that you'd like to be visible as public e.g.

public string ProjectId {get;set;}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文