+ Start a Discussion
Rajat MahajanRajat Mahajan 

Inline Edit in pageblock section



I am trying to use the following code, which is not allowing me to save the entry, i am redirected to the home  page after i click on save, when i go back to the page, i see the old values


Request you to please help me with this :


Visual Force Page ================================================================================


<apex:page standardController="Account" recordSetvar="accounts" extensions="AccountPagination">
  <apex:pageBlock title="Viewing Accounts" >
  <apex:form id="theForm">
    <apex:pageBlockSection >
    <!--  <apex:dataList var="a" value="{!accountPagination}" type="1">
        </apex:dataList>  -->
         <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" hideOnEdit="editButton" />
         <apex:pageblockTable value="{!accountPagination}" var="e" id="table2" columns="21" style="width:130%">
                  <apex:column headervalue="Accounts">
                        <apex:outputField id="accounts" value="{!e.name}"/> &nbsp;
              <apex:commandButton value="Edit" action="{!save}" id="editButton" />
                <apex:commandButton value="Save" action="{!save}" id="saveButton" />
                <apex:commandButton value="Cancel" action="{!cancel}" id="cancelButton" />
    <apex:panelGrid columns="2">
      <apex:commandLink action="{!previous}">Previous</apex:commandlink>
      <apex:commandLink action="{!next}">Next</apex:commandlink>


Apex Class ======================================================================================


public with sharing class AccountPagination {
    private final Account acct;  

    // The constructor passes in the standard controller defined below
 // in the Visualforce markup
    public AccountPagination(ApexPages.StandardSetController controller) {
       this.acct = (Account)controller.getRecord();
    public ApexPages.StandardSetController accountRecords{
        get {
            if(accountRecords == null) {
                return new ApexPages.StandardSetController(Database.getQueryLocator(
                [SELECT name FROM Account WHERE Id NOT IN (SELECT AccountId
                FROM Opportunity WHERE IsClosed = false) limit : 20]));
            return accountRecords;
        private set;
    public List<Account> getAccountPagination() {
         return (List<Account>) accountRecords.getRecords();



Since you are trying the standard method for Save ,Cancel etc which will work fine for Standard Controller but when you are doing some manipulation inside your controller with extension in VF page you have to overwrite the Save method inside your controller. So you have pass the id of pericular record into controller using apex:param tag.


Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 


StandardController will only save the data that was loaded by StandardController.   In your case, it seems like you have loaded the data in your extension so you need to save it there also. 


Add a save method to your extension and put the save logic there.   If you want to also save the data that was loaded by the standard controller, you can call its save method from yours.