我用谷歌搜索了很多,但我没有找到解决我错误的方法。
我收到错误未知属性' Integer.count_u18'。
我希望你能帮助我。
谢谢, PEX
视力部队页面
<apex:page standardController="Account" extensions="Gruppenvertrag_c9">
<apex:form >
<apex:pageBlock Title="Long ID lautet">
<apex:outputText value="{!Account.ID}"/>
</apex:pageBlock>
<apex:pageBlock title="Count of Ages">
<apex:pageBlockTable value="{!Einzelrisiko}" var="EZR">
<apex:column value="{!EZR.Count_u18}"/>
<apex:column value="{!EZR.Count_1822}"/>
<apex:column value="{!EZR.Count_2227}"/>
<apex:column value="{!EZR.Count_2732}"/>
<apex:column value="{!EZR.Count_3237}"/>
<apex:column value="{!EZR.Count_3742}"/>
<apex:column value="{!EZR.Count_4247}"/>
<apex:column value="{!EZR.Count_4752}"/>
<apex:column value="{!EZR.Count_5257}"/>
<apex:column value="{!EZR.Count_g57}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
CLASS
公共课Gruppenvertrag_c9 {
private Id accId {get; set;}
public Gruppenvertrag_c9(ApexPages.StandardController stdcontroller) {
accId = stdcontroller.getRecord().Id;
}
public Integer getEinzelrisiko() {
//List<Einzelrisiko__c> listEZR = [SELECT COUNT() FROM Einzelrisiko__c WHERE Abgangsdatum__c = Null AND Unternehmens_Id_Long__c = :accId];
List<Einzelrisiko__c> listEZR = [SELECT Alter__c FROM Einzelrisiko__c WHERE Abgangsdatum__c = Null AND Unternehmens_Id_Long__c = :accId];
Integer Count_u18 = 0;
Integer Count_1822 = 0;
Integer Count_2227 = 0;
Integer Count_2732 = 0;
Integer Count_3237 = 0;
Integer Count_3742 = 0;
Integer Count_4247 = 0;
Integer Count_4752 = 0;
Integer Count_5257 = 0;
Integer Count_g57 = 0;
FOR(Einzelrisiko__c ein : listEZR) {
IF(ein.Alter__c < 18) { Count_u18++; }
IF(ein.Alter__c >18 && ein.Alter__c <=22) { Count_1822++; }
IF(ein.Alter__c >22 && ein.Alter__c <=27) { Count_2227++; }
IF(ein.Alter__c >27 && ein.Alter__c <=32) { Count_2732++; }
IF(ein.Alter__c >32 && ein.Alter__c <=37) { Count_3237++; }
IF(ein.Alter__c >37 && ein.Alter__c <=42) { Count_3742++; }
IF(ein.Alter__c >42 && ein.Alter__c <=47) { Count_4247++; }
IF(ein.Alter__c >47 && ein.Alter__c <=52) { Count_4752++; }
IF(ein.Alter__c >52 && ein.Alter__c <=57) { Count_5257++; }
IF(ein.Alter__c >57) { Count_g57++; }
}
return Count_u18;
return Count_1822;
return Count_2227;
return Count_2732;
return Count_3237;
return Count_3742;
return Count_4247;
return Count_4752;
return Count_5257;
return Count_g57;
}
}
答案 0 :(得分:1)
getEinzelrisiko()
方法存在问题。此方法返回Integer
,PageblockTable
值属性应为List
类型。
我已更改Visualforce Page
和Apex Class
,请检查此内容。
Visualforce :
<apex:page standardController="Account" extensions="Gruppenvertrag_c9">
<apex:form >
<apex:pageBlock Title="Long ID lautet">
<apex:outputText value="{!Account.ID}"/>
</apex:pageBlock>
<apex:pageBlock title="Count of Ages">
<apex:pageBlockTable value="{!CountList}" var="EZR">`//Changed Value Attribute.`
<apex:column value="{!EZR.Count_u18}"/>
<apex:column value="{!EZR.Count_1822}"/>
<apex:column value="{!EZR.Count_2227}"/>
<apex:column value="{!EZR.Count_2732}"/>
<apex:column value="{!EZR.Count_3237}"/>
<apex:column value="{!EZR.Count_3742}"/>
<apex:column value="{!EZR.Count_4247}"/>
<apex:column value="{!EZR.Count_4752}"/>
<apex:column value="{!EZR.Count_5257}"/>
<apex:column value="{!EZR.Count_g57}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex :
public class Gruppenvertrag_c9 {
private Id accId {get; set;}
public List<CountClass> CountList {get;set;} //this list contains all the values and binded to Pageblocktable
public Gruppenvertrag_c9(ApexPages.StandardController stdcontroller) {
accId = stdcontroller.getRecord().Id;
getEinzelrisiko();//called in the constructor.
}
public void getEinzelrisiko() {
//List<Einzelrisiko__c> listEZR = [SELECT COUNT() FROM Einzelrisiko__c WHERE Abgangsdatum__c = Null AND Unternehmens_Id_Long__c = :accId];
List<Einzelrisiko__c> listEZR = [SELECT Alter__c FROM Einzelrisiko__c WHERE Abgangsdatum__c = Null AND Unternehmens_Id_Long__c = :accId];
CountList = new List<CountClass>();
FOR(Einzelrisiko__c ein : listEZR) {
CountClass cc = new CountClass();
IF(ein.Alter__c < 18) { cc.Count_u18++; }
IF(ein.Alter__c >18 && ein.Alter__c <=22) { cc.Count_1822++; }
IF(ein.Alter__c >22 && ein.Alter__c <=27) { cc.Count_2227++; }
IF(ein.Alter__c >27 && ein.Alter__c <=32) { cc.Count_2732++; }
IF(ein.Alter__c >32 && ein.Alter__c <=37) { cc.Count_3237++; }
IF(ein.Alter__c >37 && ein.Alter__c <=42) { cc.Count_3742++; }
IF(ein.Alter__c >42 && ein.Alter__c <=47) { cc.Count_4247++; }
IF(ein.Alter__c >47 && ein.Alter__c <=52) { cc.Count_4752++; }
IF(ein.Alter__c >52 && ein.Alter__c <=57) { cc.Count_5257++; }
IF(ein.Alter__c >57) { cc.Count_g57++; }
CountList.add(cc);//adding each record to the list
}
}
public class CountClass
{
public Integer Count_u18 {get;set;}
public Integer Count_1822 {get;set;}
public Integer Count_2227 {get;set;}
public Integer Count_2732 {get;set;}
public Integer Count_3237 {get;set;}
public Integer Count_3742 {get;set;}
public Integer Count_4247 {get;set;}
public Integer Count_4752 {get;set;}
public Integer Count_5257 {get;set;}
public Integer Count_g57 {get;set;}
public CountClass()
{
Count_u18 = 0;
Count_1822 = 0;
Count_2227 = 0;
Count_2732 = 0;
Count_3237 = 0;
Count_3742 = 0;
Count_4247 = 0;
Count_4752 = 0;
Count_5257 = 0;
Count_g57 = 0;
}
}
}
希望它可以帮到你
答案 1 :(得分:0)
我已将查询拆分为两个查询,并且测试可以正常运行。 但是,现在我得到了一个查询列表,但我只想查询一下。可以再次查看代码。
谢谢, 的Sascha
<apex:page standardController="Account" extensions="Gruppenvertrag_c55,Gruppenvertrag_c56">
<apex:form >
<apex:pageBlock Title="Long ID lautet">
<apex:outputText value="{!Account.ID}"/>
</apex:pageBlock>
<apex:pageBlock title="Count of Ages">
<apex:pageBlockTable value="{!CountList2}" var="EZR2">
<apex:column value="{!EZR2.Count_u18}"/>
<apex:column value="{!EZR2.Count_1822}"/>
<apex:column value="{!EZR2.Count_2227}"/>
<apex:column value="{!EZR2.Count_2732}"/>
<apex:column value="{!EZR2.Count_3237}"/>
</apex:pageBlockTable>
</apex:pageBlock>
<apex:pageBlock title="Count of Ages">
<apex:pageBlockTable value="{!CountList}" var="EZR">
<apex:column value="{!EZR.Count_3742}"/>
<apex:column value="{!EZR.Count_4247}"/>
<apex:column value="{!EZR.Count_4752}"/>
<apex:column value="{!EZR.Count_5257}"/>
<apex:column value="{!EZR.Count_g57}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
public class Gruppenvertrag_c55 {
private Id accId {get; set;}
public List<CountClass> CountList {get;set;} //this list contains all the values and binded to Pageblocktable
public Gruppenvertrag_c55(ApexPages.StandardController stdcontroller) {
accId = stdcontroller.getRecord().Id;
getEinzelrisiko();//called in the constructor.
}
public void getEinzelrisiko() {
List<Einzelrisiko__c> listEZR = [SELECT Alter__c FROM Einzelrisiko__c WHERE Abgangsdatum__c = Null AND Unternehmens_Id_Long__c = :accId AND Alter__c >=42];
CountList = new List<CountClass>();
FOR(Einzelrisiko__c ein : listEZR) {
CountClass cc = new CountClass();
IF(ein.Alter__c >37 && ein.Alter__c <=42) { cc.Count_3742++; }
IF(ein.Alter__c >42 && ein.Alter__c <=47) { cc.Count_4247++; }
IF(ein.Alter__c >47 && ein.Alter__c <=52) { cc.Count_4752++; }
IF(ein.Alter__c >52 && ein.Alter__c <=57) { cc.Count_5257++; }
IF(ein.Alter__c >57) { cc.Count_g57++; }
CountList.add(cc);//adding each record to the list
}
}
public class CountClass
{
public Integer Count_3742 {get;set;}
public Integer Count_4247 {get;set;}
public Integer Count_4752 {get;set;}
public Integer Count_5257 {get;set;}
public Integer Count_g57 {get;set;}
public CountClass()
{
Count_3742 = 0;
Count_4247 = 0;
Count_4752 = 0;
Count_5257 = 0;
Count_g57 = 0;
}
}
}