0

I have the problem that my editable table does not update when I hit the "save" button. I tried inline editing and normal editing, nothing would save. Although I referred to a standard controller, I prefer the solution with a custom controller.

<apex:page standardController="Dev_Request__c" extensions="tableDevRequest_edit">
    <apex:form >
        <apex:pageblock mode="inlineEdit"> 
            <apex:pageMessages />  
            <apex:pageBlockButtons > 
            <!--<apex:commandButton value="Save" action="{!saveTable}" id="saveButton" rendered="{!editTable==true}" immediate="true"/>-->
            <apex:commandButton value="Save" action="{!saveTable}" id="saveButton" immediate="true"/>
            <apex:commandButton id="cancelButton" value="Cancel"/> 
            </apex:pageBlockButtons>  

             <apex:pageblocktable value="{!lstDevRequest_edit}"  var="item">
                    <apex:column headerValue="Dev Request Name"><apex:actionRegion ><apex:outputField value="{!item.Name}"><apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" /></apex:outputField></apex:actionRegion></apex:column>
                    <apex:column headerValue="Id"><apex:outputField value="{!item.Id}"/></apex:column>
                    <apex:column headerValue="Status"><apex:inputField value="{!item.Status__c}"/></apex:column>
                    <apex:column headerValue="Start Date"><apex:inputField value="{!item.Start_Date__c}"/></apex:column>
                    <apex:column headerValue="Due Date QA"><apex:inputField value="{!item.Due_Date_QA__c}"/></apex:column>
                    <apex:column headerValue="Estimated Hours"><apex:inputField value="{!item.Estimated_Hours__c}"/></apex:column>
                    <apex:column headerValue="Assignee"><apex:inputField value="{!item.Assignee__c}"/></apex:column>
                    <apex:column headerValue="Overview"><apex:inputField value="{!item.Overview__c}"/></apex:column>
             </apex:pageblocktable>

        </apex:pageblock>
    </apex:form>

public with sharing class tableDevRequest_edit {

   public List<Dev_Request__c> lstDevRequest_edit {get;set;}

    public tableDevRequest_edit(ApexPages.StandardController controller) {
        lstDevRequest_edit = [Select Id, Name, Assignee__c, Assignee__r.Name, Start_Date__c, Due_Date_QA__c, Estimated_Hours__c, Estimated_Completion_Date__c, Status__c, Overview__c from Dev_Request__c];
    }

    public PageReference saveTable() {
        try {
            update lstDevRequest_edit;
        }   
        catch(Exception e){
            System.debug('Exception occurred '+String.valueOf(e));
        }
        return NULL;
    }     
}

Thank you for helping!

  • Have you checked your debug log and see which exception have you got? I bet there is an exception happening here. – Lance Shi Jan 23 '17 at 6:26
  • try to use catch(Exception ex) { ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.Error, ex.getMessage()); ApexPages.addMessage(msg); } – Santanu Boral Jan 23 '17 at 6:29
  • Thanks, but how would I see this then? Visual force does not debug, would I have to call the method from the console? – user40501 Jan 23 '17 at 6:33
0

I got the solution, I needed to remove the statement immediate="true".

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.