1

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:outputPanel id="ContactDetail">
<apex:repeat value="{! displayContacts}" var="contact">
<p>{! contact.name & ' ' & contact.title}</p>
</apex:repeat>
</apex:outputPanel>

</apex:form>>
</apex:page>

Apex controller

public class recordPageCont {
public Account objAccount{get;set;}
Public string recId{get;set;}
Contact[] displayContacts {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 ];

                        Account[] accts =[SELECT Name, AccountNumber ,Type , Industry , Rating,(SELECT Name , MobilePhone,Title from Contacts) 
                 FROM account
                 WHERE ID = :recId ];

Account acct = accts[0];
//acct.Contacts is a List<Contact>
if (!objAccount.Contacts.isEmpty()){
    displayContacts = acct.Contacts;

    }}


    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;
    }


}

I am trying to display related list contacts from displaycontact array, but when iIam using displaycontacts.name in my Visualforce page I'm getting an error.

Error: Unknown property 'recordPageCont.displayContacts'
Quick Fix Create Apex property 'recordPageCont.displayContacts'
Quick Fix Create Apex method 'recordPageCont.getDisplayContacts'

What is wrong with this?

<apex:outputPanel id="ContactDetail">
<apex:repeat value="{! displayContacts}" var="contact">
<p>{! contact.name & ' ' & contact.title}</p>
</apex:repeat>
</apex:outputPanel>

I tried with datalist table as well and still I'm getting the same error.

1 Answer 1

2

Based on your inputs its looks like you have missed "Public" access declaration for your property: Replace this: Contact[] displayContacts {get;set;} with Public Contact[] displayContacts {get;set;}.

This should solve your problem. Let me knom if it's not.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .