You need to sign in to do that
Don't have an account?

Here i am not getting Account Id
<apex:page standardController="Account" extensions="contrller">
<apex:form >
<apex:pageblock >
<!-- Display Account related Contacts -->
<apex:pageBlockTable value="{!relatedContacts}" var="val">
<apex:column value="{!val.name}"/>
<apex:column value="{!val.email}"/>
</apex:pageBlockTable>
</apex:pageblock>
</apex:form>
</apex:page>
_________controller_______________
public with sharing class contrller {
Public id Current_Acc_Id;
public contrller(ApexPages.StandardController controller) {
Current_Acc_Id = controller.getRecord().id;
system.debug('--------------------Current_Acc_Id------------------------'+Current_Acc_Id );
}
public List<Contact> getrelatedContacts(){
List <contact> conList = New List<Contact>();
system.debug('--------------------Current_Acc_Id------------------------'+Current_Acc_Id );
for(Account acc:[select id,name,(select name,id,email from contacts) from account where id=:Current_Acc_Id])
{
for(contact con:acc.contacts)
conList.add(con);
}
return conList;
}
no records are displayed
<apex:form >
<apex:pageblock >
<!-- Display Account related Contacts -->
<apex:pageBlockTable value="{!relatedContacts}" var="val">
<apex:column value="{!val.name}"/>
<apex:column value="{!val.email}"/>
</apex:pageBlockTable>
</apex:pageblock>
</apex:form>
</apex:page>
_________controller_______________
public with sharing class contrller {
Public id Current_Acc_Id;
public contrller(ApexPages.StandardController controller) {
Current_Acc_Id = controller.getRecord().id;
system.debug('--------------------Current_Acc_Id------------------------'+Current_Acc_Id );
}
public List<Contact> getrelatedContacts(){
List <contact> conList = New List<Contact>();
system.debug('--------------------Current_Acc_Id------------------------'+Current_Acc_Id );
for(Account acc:[select id,name,(select name,id,email from contacts) from account where id=:Current_Acc_Id])
{
for(contact con:acc.contacts)
conList.add(con);
}
return conList;
}
no records are displayed
You can refer to below link:
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_system_pagereference.htm
Sample code:
Public Class getrid {
public string rid{get;set;}
Public getrid ( Apexpages.standardcontroller controller) {
rid=apexpages.currentpage().getparameters().get('id');
}
}
Thanks,
Pratik
P.S. If this answers you question, please mark it as "Best Answer" so it will help other community members too.
please pass the account id in your URL then it will return you the id of the current record in context.