I have created a page which displays records of account tab.the page that displays a list of record is pasted below. what i want to implement is ..where i click a record,it should diplays the detail of record and this shold be done through apex.I have achieved this functionaloty but i am not sure how to fetch the related contatc from the SOQL ojct
VF page
<apex:page controller="recordPageCont">
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="Edit" action="{!EditAccount}"/>
<apex:commandButton value="Cancel" action="{!CancelButton}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection >
<apex:outputField value="{!objAccount.Name}"/>
<apex:outputField value="{!objAccount.AccountNumber} "/>
<apex:outputField value="{!objAccount.Type} "/>
<apex:outputField value="{!objAccount.industry} "/>
<apex:outputField value="{!objAccount.Rating} "/>
<b>Email</b> {!objAccount.Name}@salesforce.com
<apex:outputField value="{!objAccount.Rating} "/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
<apex:pageBlock title="Contacts Related With {!objaccount.name}"></apex:pageBlock>
<apex:form >
</apex:form>>
</apex:page>
below is my apex page.
what this pagedoes is fetch the details of the record which is clicked.
The id of the record is in variabla recId What my question is how to display contact on the vf page. some one told me that i have to iterate through the object "objAccount" to get the contact.
Please let me know how to do this
public class recordPageCont {
public Account objAccount{get;set;}
Public string recId{get;set;}
public recordPageCont ()
{
recId = apexpages.currentpage().getparameters().get('id');
objAccount =[SELECT Name, AccountNumber ,Type , Industry , Rating,(SELECT Name , MobilePhone,Title from Contacts)
FROM account
WHERE ID = :recId ];
}
Public pagereference Editaccount()
{
Pagereference edtaccount = new Pagereference('/apex/editaccount?id='+recid);
edtaccount.setredirect(true);
return edtaccount;
}
public pagereference cancelButton()
{
Pagereference cnclbutton = new Pagereference('/apex/accountdisplay');
cnclbutton.setredirect(true);
return cnclbutton;
}
}