I am trying to create a custom tab just like Accounts Tab.
I was able to fetch the detail on my custom tab.but I donot have any idea how i need to get the related list like contact which is related to the record i am opening
My apex code is
<apex:page controller="ClassRetrieve" >
<apex:panelGrid columns="2">
<apex:form >
<apex:commandButton value="New Account" action="{!NewAccount}"/>
<p></p>
<apex:pageBlock >
<apex:pageBlockTable value="{!accs}" var="a">
<apex:column headerValue="Name" >
<apex:commandLink value="{!a.name}" action="{!accountClicked}">
<apex:param name="nickName"
value="{!a.id}"
assignTo="{!recordId}"/>
</apex:commandLink>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:panelGrid>
</apex:page>
My controller
public class ClassRetrieve {
Public string recordId{get;set;}
public List<Account> contactsInformation { get; set; }
public list<Account> accs {get;set;}
public ClassRetrieve()
{
accs = [Select Id,Name From Account];
}
public pagereference accountClicked()
{
pagereference redirect = new PageReference('/apex/recordPage?id='+recordId);
redirect.setRedirect(true);
return redirect;
}
Public pagereference NewAccount()
{
pagereference newAccpage = new pagereference('/apex/newAccount');
newaccpage.setredirect(true);
return newaccpage;
}
}
Page that displays the record is like
VF page
<apex:page controller="recordPageCont">
create an custom email Field on account
add edit / cancel buton <br/>
add realted list using repeter eg Contacts using soql query
<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:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
apex is
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 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;
}
}
please help..Any idea is welcome :)
apex:relatedList
component. None of the above requires apex.