0

How can I reload a table on a VF page that uses Account as the standard controller? I have an extension as well which supplies the data to the table.

Visualforce Page:

<apex:page standardController="account" extensions="AccountDimensionViewExtension"> 
    <apex:form id="accountView">     
        <apex:pageBlock title="Primary End Use Market" id="marketList" rendered="{!Account.RecordType.Name='Account'}">

            <apex:pageBlockTable value="{!markets}" var="item">
                <apex:column headervalue="Primary End Use Market" value="{!item.ParentId__r.Name}"/>
                <apex:column headervalue="Primary EUM Sector" value="{!item.Name}"/>
            </apex:pageBlockTable> 

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

Extension:

public class AccountDimensionViewExtension {

    Account account;

    public accountDimensionViewExtension(ApexPages.StandardController controller) {
        this.account = (Account)controller.getRecord();
        this.account = [Select id, Primary_EUM__c
                        from Account
                        where id = :this.account.id];
    }

    public List<Hierarchy__c> getMarkets() {
        return getPrimaryEUMInfo();
    } 

    public List<Hierarchy__c> getPrimaryEUMInfo() {
            List<Hierarchy__c> subSectorList = [SELECT id, Name, ParentId__c, parentId__r.Name, LastModifiedById, LastModifiedDate FROM Hierarchy__c WHERE ParentId__c =: this.account.Primary_EUM__c];
            return subSectorList;
    } 
}

When I change Primary_EUM__c (which is a look up to Hierarchy__c) on the account my table doesn't update on save. If I refresh the page then the table does update however ideally I want the VF table to update on save.

I have tried using PageReference to force a page refresh but I'm not sure implement it since I need to return List<Hierarchy__c> and not PageReference so that I have data for the table.

  • 2
    Is this your complete visualforce code ? Because I can't see the Save commandButton. Ideally, you can use the rerender attribute of commandButton and provide the id of your table in that attribute. – Vijay Ganji Jul 4 '19 at 13:10
  • It is all the visualforce code. Because I am using the standard controller I am using the standard buttons also – Luke Bray Jul 4 '19 at 13:11
  • 1
    For using standard actions as well you need to write the visualforce code so that the buttons appear on the page. Can you confirm if you are able to see the buttons on the page ? – Vijay Ganji Jul 4 '19 at 13:26
  • I can see the buttons on the page. The table in the VF above is only designed to appear like a related list at the bottom of the standard record. – Luke Bray Jul 4 '19 at 13:39
  • is this a VF page embedded as a component on the standard Account detail page? How/where does account.Primary_EUM__c get changed? – cropredy Jul 4 '19 at 18:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.