2
我正在構建控制器以顯示Visualforce頁面上自定義對象的數據。這是我的課程:Salesforce - 無效的構造函數名稱錯誤
public class myController {
Opportunity opp;
list<Leg__c> legs;
public Opportunity getOpp() {
if(opp == null)
opp = [select name, Primary_Contact__r.name, Primary_Contact__r.email, Primary_Contact__r.phone from Opportunity
where id = :ApexPages.currentPage().getParameters().get('id')];
return opp;
}
public getLegs() {
legs = [select Departure__c, Arrival__c from Leg__c
where Opportunity__c = :ApexPages.currentPage().getParameters().get('id')];
}
}
我無法得到它編譯!我不斷收到
Error: myController Compile Error: Invalid constructor name: getLegs at line 12 column 12
我在做什麼錯,怎麼解決?
完美!我沒有意識到我實際上應該使用一個函數(非常新的頂點哈哈) –