function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Stacey McDonaldStacey McDonald 

Save Button Not Working

I created a visual force page with Account Details at the top and a contact related list at the bottom.  I have Save and Cancel buttons on the page.  The Save button works after I modify a contact but does not save the modification when I change one of the account fields.  Here is my code.

---VF Page---
<apex:page standardController="Account" showHeader="true" sidebar="true" extensions="EditableContactListExtension">
    <apex:form >  
      <apex:pageMessages id="messages"/>
        <apex:pageBlock title="Account Penetration" mode="edit">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
                <apex:commandButton action="{!cancel}" value="Cancel"/>
                <apex:commandButton value="Print Profile" action="{!URLFOR($Action.Account.View,Account.Id)}" onclick="openConga()"/>
                <Script Language="JavaScript">function openConga() { window.open('{!URLFOR($Action.Account.Penetration_Profile,Account.Id)}', '','scrollbars=yes,menubar=no,height=600,width=800,resizable=yes, toolbar=no,location=no,status=yes'); }  
                </Script>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="Contact Penetration" columns="3">
                <apex:outputField value="{!account.Architect_Contacts__c}"/>
                <apex:outputField value="{!account.Design_Contacts__c}"/>
                <apex:outputField value="{!account.Total_Contacts__c}"/>
                <apex:outputField value="{!account.Architects_Engaged_6_Months__c}"/>
                <apex:outputField value="{!account.Designers_Engaged_6_Months__c}"/>
                <apex:outputField value="{!account.Total_Engaged_6_Months__c}"/>
                <apex:outputField value="{!account.Architect_Penetration__c}"/>
                <apex:outputField value="{!account.Design_Penetration__c}"/>
                <apex:outputField value="{!account.Total_Penetration__c}"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Specification Share of Wallet" columns="2">
                <apex:inputField value="{!account.Total_Annual_Specifications_Number__c}"/>
                <apex:inputField value="{!account.Total_Annual_Specifications_Sales__c}"/>
                <apex:inputField value="{!account.Koroseal_Specs_TTM_Number__c}"/>
                <apex:inputField value="{!account.Koroseal_Specs_TTM_Sales__c}"/>
                <apex:outputField value="{!account.Share_of_Wallet_Number__c}"/>
                <apex:outputField value="{!account.Share_of_Wallet_Sales__c}"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Specification Win Rate" columns="1">
                <apex:outputField value="{!account.Koroseal_Specs_TTM__c}"/>
                <apex:inputField value="{!account.Specifications_Won__c}"/>
                <apex:inputField value="{!account.Specifications_Lost__c}"/>
                <apex:outputField value="{!account.Specification_Win_Rate__c}"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection id="childList" columns="1" title="Known Contacts" collapsible="false">
        	  <!-- There is a trick to creating a counter when rendering rows in a
              pageBlockTable. You have to define a variable to default to 0,
              and then update that variable inside the table row. This is the
              way that I can leverage smart row deletes -->
        <apex:variable var="rowNum" value="{!ZERO}" />
        <apex:outputLabel value="No Contacts currently exist. Click below to Add." rendered="{!NOT(hasChildren)}"/>
        <apex:pageBlockTable value="{!children}" var="contact" rendered="{!hasChildren}" >
          <apex:column headerValue="First Name">
            <apex:inputField value="{!contact.FirstName}" />
          </apex:column>
          <apex:column headerValue="Last Name">
            <apex:inputField value="{!contact.LastName}" />
          </apex:column>
            <!-- Add additional children metadata columns here -->
          <apex:column headerValue="Studio">
            <apex:inputField value="{!contact.Studio__c}" />
          </apex:column>
          <apex:column headerValue="Type">
            <apex:inputField value="{!contact.Type__c}" />
          </apex:column>
          <apex:column headerValue="Preferred Contact Frequency">
            <apex:inputField value="{!contact.Preferred_Contact_Frequency__c}" />
          </apex:column>
          <apex:column headerValue="Date Last Contacted">
            <apex:inputField value="{!contact.Date_Last_Contacted__c}" />
          </apex:column>
          <apex:column headerValue="Days Since Contact">
            <apex:inputField value="{!contact.Days_Since_Contact__c}" />
          </apex:column>  
            <!-- This is the second half of the trick to keep track
                  of your row index for deletion. -->
            <apex:variable var="rowNum" value="{!rowNum + 1}" />
            <apex:commandLink value="Delete" action="{!removeFromList}" rerender="childList, messages" immediate="true">
              <apex:param name="removeIndex" assignTo="{!removeIndex}" value="{!rowNum}" />
            </apex:commandLink>
        </apex:pageBlockTable>
        <!-- Want to specify immediate here and above so validation does
              not occur when you are trying to add/remove rows. Only want
              validation to occur when trying to save -->
        <apex:commandButton value="Add Contact" action="{!addToList}" rerender="childList, messages" immediate="true" />
      	</apex:pageBlockSection>
      </apex:pageBlock>
    </apex:form>
</apex:page>
Thanks!
Best Answer chosen by Stacey McDonald
SlashApex (Luis Luciani)SlashApex (Luis Luciani)
Hi Stacey,

Absolutely! I am going to put here the final code with the slight modification to the controller so that it redirects to the account.

VF:
 
<apex:page standardController="Account" showHeader="true" sidebar="true" extensions="EditableContactListExtension">
    <apex:form >  
      <apex:pageMessages id="messages"/>
        <apex:pageBlock title="Account Penetration" mode="edit">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!saveAll}" value="Save"/>
                <apex:commandButton action="{!cancel}" value="Cancel"/>
                <apex:commandButton value="Print Profile" action="{!URLFOR($Action.Account.View,Account.Id)}" onclick="openConga()"/>
                <Script Language="JavaScript">function openConga() { window.open('{!URLFOR($Action.Account.Penetration_Profile,Account.Id)}', '','scrollbars=yes,menubar=no,height=600,width=800,resizable=yes, toolbar=no,location=no,status=yes'); }  
                </Script>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="Contact Penetration" columns="3">
                <apex:outputField value="{!account.Architect_Contacts__c}"/>
                <apex:outputField value="{!account.Design_Contacts__c}"/>
                <apex:outputField value="{!account.Total_Contacts__c}"/>
                <apex:outputField value="{!account.Architects_Engaged_6_Months__c}"/>
                <apex:outputField value="{!account.Designers_Engaged_6_Months__c}"/>
                <apex:outputField value="{!account.Total_Engaged_6_Months__c}"/>
                <apex:outputField value="{!account.Architect_Penetration__c}"/>
                <apex:outputField value="{!account.Design_Penetration__c}"/>
                <apex:outputField value="{!account.Total_Penetration__c}"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Specification Share of Wallet" columns="2">
                <apex:inputField value="{!account.Total_Annual_Specifications_Number__c}"/>
                <apex:inputField value="{!account.Total_Annual_Specifications_Sales__c}"/>
                <apex:inputField value="{!account.Koroseal_Specs_TTM_Number__c}"/>
                <apex:inputField value="{!account.Koroseal_Specs_TTM_Sales__c}"/>
                <apex:outputField value="{!account.Share_of_Wallet_Number__c}"/>
                <apex:outputField value="{!account.Share_of_Wallet_Sales__c}"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Specification Win Rate" columns="1">
                <apex:outputField value="{!account.Koroseal_Specs_TTM__c}"/>
                <apex:inputField value="{!account.Specifications_Won__c}"/>
                <apex:inputField value="{!account.Specifications_Lost__c}"/>
                <apex:outputField value="{!account.Specification_Win_Rate__c}"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection id="childList" columns="1" title="Known Contacts" collapsible="false">
        	  <!-- There is a trick to creating a counter when rendering rows in a
              pageBlockTable. You have to define a variable to default to 0,
              and then update that variable inside the table row. This is the
              way that I can leverage smart row deletes -->
        <apex:variable var="rowNum" value="{!ZERO}" />
        <apex:outputLabel value="No Contacts currently exist. Click below to Add." rendered="{!NOT(hasChildren)}"/>
        <apex:pageBlockTable value="{!children}" var="contact" rendered="{!hasChildren}" >
          <apex:column headerValue="First Name">
            <apex:inputField value="{!contact.FirstName}" />
          </apex:column>
          <apex:column headerValue="Last Name">
            <apex:inputField value="{!contact.LastName}" />
          </apex:column>
            <!-- Add additional children metadata columns here -->
          <apex:column headerValue="Studio">
            <apex:inputField value="{!contact.Studio__c}" />
          </apex:column>
          <apex:column headerValue="Type">
            <apex:inputField value="{!contact.Type__c}" />
          </apex:column>
          <apex:column headerValue="Preferred Contact Frequency">
            <apex:inputField value="{!contact.Preferred_Contact_Frequency__c}" />
          </apex:column>
          <apex:column headerValue="Date Last Contacted">
            <apex:inputField value="{!contact.Date_Last_Contacted__c}" />
          </apex:column>
          <apex:column headerValue="Days Since Contact">
            <apex:inputField value="{!contact.Days_Since_Contact__c}" />
          </apex:column>  
            <!-- This is the second half of the trick to keep track
                  of your row index for deletion. -->
            <apex:variable var="rowNum" value="{!rowNum + 1}" />
            <apex:commandLink value="Delete" action="{!removeFromList}" rerender="childList, messages" immediate="true">
              <apex:param name="removeIndex" assignTo="{!removeIndex}" value="{!rowNum}" />
            </apex:commandLink>
        </apex:pageBlockTable>
        <!-- Want to specify immediate here and above so validation does
              not occur when you are trying to add/remove rows. Only want
              validation to occur when trying to save -->
        <apex:commandButton value="Add Contact" action="{!addToList}" rerender="childList, messages" immediate="true" />
      	</apex:pageBlockSection>
      </apex:pageBlock>
    </apex:form>
</apex:page>

Controller:
 
/*
 * EditableContactListExtension.cls
 *
 * Copyright (c)2013, Michael Welburn.
 * License: MIT
 *
 * Usage:
 *   This is the implementation class where Object specific references
 *   need to be defined. Please see EditableList.cls for more information
 *   on what each method is responsible for.
 *
 *   Required methods:
 *     - EditableContactListExtension(ApexPages.StandardController)
 *     - getChildren()
 *     - initChildRecord()
 *
 */
public with sharing class EditableContactListExtension extends EditableList
{
  // Read the explanation in EditableContactListExtension(ApexPages.StandardController)
  // to see when to uncomment the following line.

  // public Account myAccount {get; private set;}

public ApexPages.StandardController controller {get;set;}

  public EditableContactListExtension(ApexPages.StandardController stdController) 
  {
    super(stdController);
    controller = stdController;

    // If necessary, explicitly query for additional metadata on parent record
    // if you are looking to display things that don't come back with the
    // StandardController. In that case, you will need to replace the "Account.X"
    // references in the Visualforce Page with references to an Account variable
    // that you will need to declare in this class (myAccount.X). I have commented out
    // an example.

    // this.myAccount = [SELECT Id,
    //                            Name,
    //                            Custom_Relationship__r.Name
    //                        FROM Account
    //                        WHERE Id =: stdController.getRecord().Id];
    
    this.childList = [SELECT Id,
                          FirstName,
                          LastName,
                          Studio__c,
                          Type__c,
                      	  Preferred_Contact_Frequency__c,
                      	  Date_Last_Contacted__c,
                          Days_Since_Contact__c
                      FROM Contact
                      WHERE AccountId =: mysObject.Id
                      ORDER BY Contact.FirstName ASC];
  }

  /*
   * This method is necessary for reference on the Visualforce page, 
   * in order to reference non-standard fields.
   */
  public List<Contact> getChildren()
  {
    return (List<Contact>)childList;
  }

  public override sObject initChildRecord()
  {
    Contact child = new Contact();
    // Can either use mysObject or acct here
    child.AccountId = mysObject.Id;
    
    return child;
  }

  public PageReference saveAll()
  {
    super.save();
    return controller.save();
  }
}

Now it should redirect back to the Account Detail page, unless you are specifically setting the saveUrl parameter on the custom button that redirects to the VF page. 

 

All Answers

SlashApex (Luis Luciani)SlashApex (Luis Luciani)
Hi Stacey,

Would you mind sharing the class: EditableContactListExtension.

I have a feeling that the problem resides on the save() method on that class.

Thanks!
PrabhaPrabha
Since your extension is not available and I am guessing that in your extension you  have variable for contact as public contact contac {get;set;} and not for account, 
and on save(), you are updating contact and not account.

If you are including account also then pls share the code, it could be buggy.
Stacey McDonaldStacey McDonald
Thanks for looking into this for me.  Here is the code for the EditableContactListExtension.
/*
 * EditableContactListExtension.cls
 *
 * Copyright (c)2013, Michael Welburn.
 * License: MIT
 *
 * Usage:
 *   This is the implementation class where Object specific references
 *   need to be defined. Please see EditableList.cls for more information
 *   on what each method is responsible for.
 *
 *   Required methods:
 *     - EditableContactListExtension(ApexPages.StandardController)
 *     - getChildren()
 *     - initChildRecord()
 *
 */
public with sharing class EditableContactListExtension extends EditableList
{
  // Read the explanation in EditableContactListExtension(ApexPages.StandardController)
  // to see when to uncomment the following line.

  // public Account myAccount {get; private set;}

  public EditableContactListExtension(ApexPages.StandardController stdController) 
  {
    super(stdController);

    // If necessary, explicitly query for additional metadata on parent record
    // if you are looking to display things that don't come back with the
    // StandardController. In that case, you will need to replace the "Account.X"
    // references in the Visualforce Page with references to an Account variable
    // that you will need to declare in this class (myAccount.X). I have commented out
    // an example.

    // this.myAccount = [SELECT Id,
    //                            Name,
    //                            Custom_Relationship__r.Name
    //                        FROM Account
    //                        WHERE Id =: stdController.getRecord().Id];
    
    this.childList = [SELECT Id,
                          FirstName,
                          LastName,
                          Studio__c,
                          Type__c,
                      	  Preferred_Contact_Frequency__c,
                      	  Date_Last_Contacted__c,
                          Days_Since_Contact__c
                      FROM Contact
                      WHERE AccountId =: mysObject.Id
                      ORDER BY Contact.FirstName ASC];
  }

  /*
   * This method is necessary for reference on the Visualforce page, 
   * in order to reference non-standard fields.
   */
  public List<Contact> getChildren()
  {
    return (List<Contact>)childList;
  }

  public override sObject initChildRecord()
  {
    Contact child = new Contact();
    // Can either use mysObject or acct here
    child.AccountId = mysObject.Id;
    
    return child;
  }
}

 
SlashApex (Luis Luciani)SlashApex (Luis Luciani)
Hi Stacey,

Would you mind also sharing the "EditableList" class. The one you just shared extends EditableList, and it seems as though the code I believe might be the cause of this is on that other class.

I think that this code will fix your issue, but I want to make sure.
 
/*
 * EditableContactListExtension.cls
 *
 * Copyright (c)2013, Michael Welburn.
 * License: MIT
 *
 * Usage:
 *   This is the implementation class where Object specific references
 *   need to be defined. Please see EditableList.cls for more information
 *   on what each method is responsible for.
 *
 *   Required methods:
 *     - EditableContactListExtension(ApexPages.StandardController)
 *     - getChildren()
 *     - initChildRecord()
 *
 */
public with sharing class EditableContactListExtension extends EditableList
{
  // Read the explanation in EditableContactListExtension(ApexPages.StandardController)
  // to see when to uncomment the following line.

  // public Account myAccount {get; private set;}

public ApexPages.StandardController controller {get;set;}

  public EditableContactListExtension(ApexPages.StandardController stdController) 
  {
    super(stdController);
    controller = stdController;

    // If necessary, explicitly query for additional metadata on parent record
    // if you are looking to display things that don't come back with the
    // StandardController. In that case, you will need to replace the "Account.X"
    // references in the Visualforce Page with references to an Account variable
    // that you will need to declare in this class (myAccount.X). I have commented out
    // an example.

    // this.myAccount = [SELECT Id,
    //                            Name,
    //                            Custom_Relationship__r.Name
    //                        FROM Account
    //                        WHERE Id =: stdController.getRecord().Id];
    
    this.childList = [SELECT Id,
                          FirstName,
                          LastName,
                          Studio__c,
                          Type__c,
                      	  Preferred_Contact_Frequency__c,
                      	  Date_Last_Contacted__c,
                          Days_Since_Contact__c
                      FROM Contact
                      WHERE AccountId =: mysObject.Id
                      ORDER BY Contact.FirstName ASC];
  }

  /*
   * This method is necessary for reference on the Visualforce page, 
   * in order to reference non-standard fields.
   */
  public List<Contact> getChildren()
  {
    return (List<Contact>)childList;
  }

  public override sObject initChildRecord()
  {
    Contact child = new Contact();
    // Can either use mysObject or acct here
    child.AccountId = mysObject.Id;
    
    return child;
  }

  public PageReference save()
  {
    super(save);
    controller.save();
    return null;
  }
}

 
SlashApex (Luis Luciani)SlashApex (Luis Luciani)
Sorry, line 78 should be : super.save();
Stacey McDonaldStacey McDonald
Luis:

Thanks again!  Here is the EditableList code.
/*
 * EditableList.cls
 *
 * Copyright (c)2013, Michael Welburn.
 * License: MIT
 *
 * Usage:
 *   This is the definition class where generic implementations of
 *   the table generating and modifications are implemented. This class
 *   should not be modified in order to implement the Visualforce table,
 *   all modifications should go in a controller extension that extends
 *   this class.
 *
 */
public abstract with sharing class EditableList 
{
  // Used to help instantiate a counter for the Visualforce table rows
  public final Integer ZERO {get; private set;}

  public sObject mysObject {get; protected set;}
  public List<sObject> childList {get; set;}
  
  // Used for removing elements from the list
  public String removeIndex {get; set;}
  @TestVisible protected List<sObject> removeChildList {get;set;} 

  public EditableList()
  {
    this.ZERO = 0;
    this.removeChildList = new List<sObject>();

    // Implementing class can initialize this to retrieve existing
    // child records, OR this can be treated as a page where only new
    // items are added. If that is the case, then leave this as is.
    this.childList = new List<sObject>();
  }

  /*
   * Need to implement the following when implementing constructor:
   *
   *  - Query for child records, including all metadata to be shown on the page
   *    - Ensure query only returns the records associated with the parent
   *  - Set query results to childList List<sObject>
   */
    public EditableList(ApexPages.StandardController stdController) 
  {
    this();

    this.mysObject = (sObject)stdController.getRecord();
  }

  /*
   * Used to determine whether to display a message or the table
   */
  public Boolean getHasChildren()
  {
    return !childList.isEmpty();
  }

  /* 
   * Need to implement the following pseudocode
   *
   *  - Initialize child record
   *  - Set any default values
   *  - Set relationship with parent
   */
  public virtual sObject initChildRecord()
  {
    // Cannot instantiate a generic sObject, must choose an actual object
    // Since this class needs to be overridden, this is a placeholder
    // implementation.
    return new Contact();
  }

  /*
   * Used to add a new row to the table
   */
  public void addToList()
  {
    childList.add(initChildRecord());
  }

  /*
   * Used to remove a particular row from the table, referencing the
   * removeIndex that is set on the Visualforce page
   */
  public void removeFromList()
  {
    try
    {
      // removeIndex is one based
      Integer rowIndex = Integer.valueOf(removeIndex) - 1;
      
      if (childList.size() > rowIndex && rowIndex >= 0)
      {
        sObject sobj = childList.remove(rowIndex);
        
        // Need to delete it if it existed in the database
        if (sobj.Id != null)
        {       
          removeChildList.add(sobj);
        }
      }
    }
    catch (Exception e)
    {
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage()));
    }
  }

  /*
   * Defines the Page that is returned upon a successful save
   */
  public virtual PageReference getSuccessURL()
  {
    PageReference pr;

    String retURL = ApexPages.currentPage().getParameters().get('retURL');
    // If retURL doesn't exist, simply return to parent record
    if (String.isBlank(retURL))
    {
      pr = new ApexPages.StandardController(mysObject).view();
    }
    else
    {
      pr = new PageReference(retURL);
    }
    
    pr.setRedirect(true);
    return pr;
  }

  /*
   * Persists the records saved in the table, or deletes existing records
   * that the user deleted in the table.
   */
  public PageReference save()
  {
    Savepoint sp = Database.setSavepoint();
            
    try
    {
      // DML Upsert isn't supported for List<sObject>, so we need to do
      // explicit separate insert and update
      List<sObject> insertChildList = new List<sObject>();
      List<sObject> updateChildList = new List<sObject>();
      for (sObject sobj : childList)
      {
        if (sobj.Id == null)
        {
          insertChildList.add(sobj);
        }
        else
        {
          updateChildList.add(sobj);
        }
      }

      insert insertChildList;
      update updateChildList;
      delete removeChildList;
      
      return getSuccessURL();
    }
    catch(Exception e)
    {
      Database.rollback(sp);
                
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage()));
            
      return null;
    } 
  } 
}

 
SlashApex (Luis Luciani)SlashApex (Luis Luciani)
Hey Stacey,

Yep, its what I suspected. Try my code out. It should be saving the contacts first, and then save any changes to the Account.
Stacey McDonaldStacey McDonald
Luis:

I get the following error when I use your code.  That is with correcting line 78 to super.save();

EditableContactListExtension: Non-virtual, non-abstract methods cannot be overriden: System.PageReference save()
SlashApex (Luis Luciani)SlashApex (Luis Luciani)
Hi Stacey,

Then do the following. Change the class "EditableContactListExtension" line 76 to this:
 
public PageReference saveAll()

Then change the VF page on line 6 to this:
 
<apex:commandButton action="{!saveAll}" value="Save"/>

That should let you save and test out the changes.
Stacey McDonaldStacey McDonald
Luis:

Awesome.  That fixed the saving issue but brought up a new one.  This VF page is launched from a detail page button.  Before when I hit save it took me back to the account detail page.  Now it just stays on the VF page.  Anyway to make it go back to the account detail page on save or cancel?
Stacey McDonaldStacey McDonald
Cancel goes back to the account detail page just fine.  It is just the save button that does not.
SlashApex (Luis Luciani)SlashApex (Luis Luciani)
Hi Stacey,

Absolutely! I am going to put here the final code with the slight modification to the controller so that it redirects to the account.

VF:
 
<apex:page standardController="Account" showHeader="true" sidebar="true" extensions="EditableContactListExtension">
    <apex:form >  
      <apex:pageMessages id="messages"/>
        <apex:pageBlock title="Account Penetration" mode="edit">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!saveAll}" value="Save"/>
                <apex:commandButton action="{!cancel}" value="Cancel"/>
                <apex:commandButton value="Print Profile" action="{!URLFOR($Action.Account.View,Account.Id)}" onclick="openConga()"/>
                <Script Language="JavaScript">function openConga() { window.open('{!URLFOR($Action.Account.Penetration_Profile,Account.Id)}', '','scrollbars=yes,menubar=no,height=600,width=800,resizable=yes, toolbar=no,location=no,status=yes'); }  
                </Script>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="Contact Penetration" columns="3">
                <apex:outputField value="{!account.Architect_Contacts__c}"/>
                <apex:outputField value="{!account.Design_Contacts__c}"/>
                <apex:outputField value="{!account.Total_Contacts__c}"/>
                <apex:outputField value="{!account.Architects_Engaged_6_Months__c}"/>
                <apex:outputField value="{!account.Designers_Engaged_6_Months__c}"/>
                <apex:outputField value="{!account.Total_Engaged_6_Months__c}"/>
                <apex:outputField value="{!account.Architect_Penetration__c}"/>
                <apex:outputField value="{!account.Design_Penetration__c}"/>
                <apex:outputField value="{!account.Total_Penetration__c}"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Specification Share of Wallet" columns="2">
                <apex:inputField value="{!account.Total_Annual_Specifications_Number__c}"/>
                <apex:inputField value="{!account.Total_Annual_Specifications_Sales__c}"/>
                <apex:inputField value="{!account.Koroseal_Specs_TTM_Number__c}"/>
                <apex:inputField value="{!account.Koroseal_Specs_TTM_Sales__c}"/>
                <apex:outputField value="{!account.Share_of_Wallet_Number__c}"/>
                <apex:outputField value="{!account.Share_of_Wallet_Sales__c}"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Specification Win Rate" columns="1">
                <apex:outputField value="{!account.Koroseal_Specs_TTM__c}"/>
                <apex:inputField value="{!account.Specifications_Won__c}"/>
                <apex:inputField value="{!account.Specifications_Lost__c}"/>
                <apex:outputField value="{!account.Specification_Win_Rate__c}"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection id="childList" columns="1" title="Known Contacts" collapsible="false">
        	  <!-- There is a trick to creating a counter when rendering rows in a
              pageBlockTable. You have to define a variable to default to 0,
              and then update that variable inside the table row. This is the
              way that I can leverage smart row deletes -->
        <apex:variable var="rowNum" value="{!ZERO}" />
        <apex:outputLabel value="No Contacts currently exist. Click below to Add." rendered="{!NOT(hasChildren)}"/>
        <apex:pageBlockTable value="{!children}" var="contact" rendered="{!hasChildren}" >
          <apex:column headerValue="First Name">
            <apex:inputField value="{!contact.FirstName}" />
          </apex:column>
          <apex:column headerValue="Last Name">
            <apex:inputField value="{!contact.LastName}" />
          </apex:column>
            <!-- Add additional children metadata columns here -->
          <apex:column headerValue="Studio">
            <apex:inputField value="{!contact.Studio__c}" />
          </apex:column>
          <apex:column headerValue="Type">
            <apex:inputField value="{!contact.Type__c}" />
          </apex:column>
          <apex:column headerValue="Preferred Contact Frequency">
            <apex:inputField value="{!contact.Preferred_Contact_Frequency__c}" />
          </apex:column>
          <apex:column headerValue="Date Last Contacted">
            <apex:inputField value="{!contact.Date_Last_Contacted__c}" />
          </apex:column>
          <apex:column headerValue="Days Since Contact">
            <apex:inputField value="{!contact.Days_Since_Contact__c}" />
          </apex:column>  
            <!-- This is the second half of the trick to keep track
                  of your row index for deletion. -->
            <apex:variable var="rowNum" value="{!rowNum + 1}" />
            <apex:commandLink value="Delete" action="{!removeFromList}" rerender="childList, messages" immediate="true">
              <apex:param name="removeIndex" assignTo="{!removeIndex}" value="{!rowNum}" />
            </apex:commandLink>
        </apex:pageBlockTable>
        <!-- Want to specify immediate here and above so validation does
              not occur when you are trying to add/remove rows. Only want
              validation to occur when trying to save -->
        <apex:commandButton value="Add Contact" action="{!addToList}" rerender="childList, messages" immediate="true" />
      	</apex:pageBlockSection>
      </apex:pageBlock>
    </apex:form>
</apex:page>

Controller:
 
/*
 * EditableContactListExtension.cls
 *
 * Copyright (c)2013, Michael Welburn.
 * License: MIT
 *
 * Usage:
 *   This is the implementation class where Object specific references
 *   need to be defined. Please see EditableList.cls for more information
 *   on what each method is responsible for.
 *
 *   Required methods:
 *     - EditableContactListExtension(ApexPages.StandardController)
 *     - getChildren()
 *     - initChildRecord()
 *
 */
public with sharing class EditableContactListExtension extends EditableList
{
  // Read the explanation in EditableContactListExtension(ApexPages.StandardController)
  // to see when to uncomment the following line.

  // public Account myAccount {get; private set;}

public ApexPages.StandardController controller {get;set;}

  public EditableContactListExtension(ApexPages.StandardController stdController) 
  {
    super(stdController);
    controller = stdController;

    // If necessary, explicitly query for additional metadata on parent record
    // if you are looking to display things that don't come back with the
    // StandardController. In that case, you will need to replace the "Account.X"
    // references in the Visualforce Page with references to an Account variable
    // that you will need to declare in this class (myAccount.X). I have commented out
    // an example.

    // this.myAccount = [SELECT Id,
    //                            Name,
    //                            Custom_Relationship__r.Name
    //                        FROM Account
    //                        WHERE Id =: stdController.getRecord().Id];
    
    this.childList = [SELECT Id,
                          FirstName,
                          LastName,
                          Studio__c,
                          Type__c,
                      	  Preferred_Contact_Frequency__c,
                      	  Date_Last_Contacted__c,
                          Days_Since_Contact__c
                      FROM Contact
                      WHERE AccountId =: mysObject.Id
                      ORDER BY Contact.FirstName ASC];
  }

  /*
   * This method is necessary for reference on the Visualforce page, 
   * in order to reference non-standard fields.
   */
  public List<Contact> getChildren()
  {
    return (List<Contact>)childList;
  }

  public override sObject initChildRecord()
  {
    Contact child = new Contact();
    // Can either use mysObject or acct here
    child.AccountId = mysObject.Id;
    
    return child;
  }

  public PageReference saveAll()
  {
    super.save();
    return controller.save();
  }
}

Now it should redirect back to the Account Detail page, unless you are specifically setting the saveUrl parameter on the custom button that redirects to the VF page. 

 
This was selected as the best answer
Stacey McDonaldStacey McDonald
Luis:

Thank you so much for your assistance.  Everything is working perfect now!
Mark DsirlMark Dsirl
My website also got same issue add to card button issue in handmade leather wallets (https://www.hentley.co/) wehsite.