I have a custom object call Account_Addresses__c that has a master-detail relationship to the Account record. I am trying to create a Visualforce page that will be embedded in the Account Detail to show the related list's records and eventually allow users to inline edit them. I have the controller and Visualforce below. Both render without error, but nothing shows on the Account even though there are records in the related list. What am I missing?
Visualforce:
<apex:page standardController="Account" extensions="AcctAddresses" tabStyle="Account" >
<apex:pageMessages />
<apex:form >
TESTING
<apex:pageblock id="AddressList">
<div style="margin-left: 30%;"><apex:commandLink value="New Address" action="{!newAddress}" target="_parent" styleClass="btn" style="text-decoration:none;padding:4px;"/></div>
<br/>
<apex:pageBlockTable value="{!addresses}" var="addr" rendered="{!NOT(ISNULL(addresses))}">
<apex:column HeaderValue="Action" width="60">
<apex:commandLink value="Edit" style="color:#015ba7;" action="{!editAddress}" target="_parent" ><apex:param value="{!addr.id}" name="AddrId"/>
</apex:commandLink>
|
<apex:commandLink value="Del" onclick="return confirm('Are you sure you want to delet this address?')" style="color:#015ba7;" action="{!deleteAddress}" target="_parent"><apex:param value="{!addr.id}" name="AddrId"/>
</apex:commandLink>
</apex:column>
<apex:column value="{!addr.Primary__c}"/>
<apex:column value="{!addr.Street__c}"/>
<apex:column value="{!addr.City__c}"/>
<apex:column value="{!addr.State__c}"/>
<apex:column value="{!addr.Zip_Postal_Code__c}"/>
<apex:column value="{!addr.Country__c}"/>
</apex:pageBlockTable>
<apex:outputLabel value="No records to display" rendered="{!(ISNULL(addresses))}" styleClass="noRowsHeader"></apex:outputLabel>
</apex:pageblock>
</apex:form>
</apex:page>
Controller:
public class AcctAddresses {
public List<Account_Addresses__c> addresses{get;set;}
public Account accounts {get;set;}
public Account acct {get;set;}
//Constructor
public AcctAddresses(ApexPages.StandardController controller) {
acct = (account)controller.getRecord();
accounts = [SELECT Id
FROM account
WHERE id=: acct.id LIMIT 1];
addresses = [SELECT Id, Primary__c, Street__c, City__c, State__c, Zip_Postal_Code__c, Country__c, Account__c
FROM Account_Addresses__c
WHERE Account__r.Id = :accounts.id ORDER BY Primary__c, State__c];
}
//This method is to create a new address while clicking on the Add Address button
public pageReference newAddress(){
pageReference pageRef = new pageReference(URL.getSalesforceBaseUrl().toExternalForm() + '/003/e?&retURL=' + accounts.id);
return pageRef;
}
//This method is to edit the existing contact record while clicking the Edit link
public pageReference editAddress(){
String contactId = Apexpages.currentpage().getParameters().get('Account_Addresses__c.Id');
pageReference pageRef = new pageReference(URL.getSalesforceBaseUrl().toExternalForm() + '/' + Account_Addresses__c.Id + '/e?retURL=' + accounts.id);
return pageRef;
}
//This method is to delete the contact record while clicking the Del link
public pageReference deleteAddress(){
String AcctAddId = Apexpages.currentpage().getParameters().get('Account_addresses__c.Id');
Account_addresses__c AddressList = [SELECT Id FROM Account_addresses__c WHERE id = : AcctAddId LIMIT 1];
delete AddressList;
String baseUrl = URL.getSalesforceBaseUrl().toExternalForm();
PageReference redirectPage = new PageReference(baseUrl+'/'+accounts.id);
return redirectPage;
}
}