I am working on the Account VF page that has a custom controller (AccountPageController). On this page I would like to add a field (customField__c) from a different CustomObject__C.
What I have tried so far is on the AccountPageController I added the following code:
public with sharing class AccountPageController {
public List<Address__C> contactList {get;set;}
public void GetAddressInfo(){
contactList=[select CustomField1__c, CustomField2__c, ID1__c, ID2__c from CustomObject__c where ID1__c = :ID or ID2__c = :ID];
}
}
And then on the VF page I have:
<apex:pageblock >
<apex:pageBlockTable value="{!contactList}" var="con">
<apex:facet name="header">Status</apex:facet>
<apex:outputtext value="{!con.CustomField1__C}"/>
</apex:pageBlockTable>
</apex:pageblock>
However, I don't receive an error but nothing shows up in that block, even if I add text. I am sure there is something wrong with my method. I'm really starting from scratch here so any help is appreciated.
Ok, so I have added that to my controller for account:
//start
public List<Address__C> contactList {
get {
if (contactList == null) {
contactList = [select Account1__c, Account2__c, CustomField__c
from CustomObject__c
where ACCOUNT1__c = :acct.id or ACCOUNT2__c = :acct.id];
}
return contactList;
} private set;
}
//end
However I don't get any errors, but I don't see those fields from the customobject__c on the account page. Where on the controller page should that code go? Does it need to go into a certain area, does it need to be a constructor? Thanks.