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
guyr1981guyr1981 

user edits inputfields of an sObject but DB not updated

Hi,

 

Getting really frustrated trying to solve a problem that is not allowing me to proceed for 2 days now.

If anyone can help, please do...

 

 

Have an Object Table_Account__c which has a few fields (lets say for simplicity):

test1__c

test2__c

test3__c

total__c

 

Also have a dataTable that presents instances of this object as inputFields on the table.

 

This is my getter for the table that is displayed later:

 

    public List<Table_Account__c> getTabAccounts() {

        this.TabAccount = [SELECT name, id, account_name__c, test1__c, test2__c, test3__c,

         Total__c from Table_Account__c];

        System.debug(Logginglevel.DEBUG, '##### I am in Get ##############################################');

        return this.TabAccount;

    }

 

The dataTable attribute creation code is:

 

<apex:page standardStylesheets="false" sidebar="false" Controller="MyController" tabStyle="Account">

....
....
....

<apex:pageBlock title="Planing Table" id="thePageBlock" mode="edit">

     <apex:dataTable value="{!TabAccounts}" id="outputTable" var="pitem" columns="10" cellPadding="6">

          <apex:column headerValue="Test1">

          <apex:inputField value="{!pitem.test1__c}" style="width: 80px"/>

           </apex:column>

          <apex:column headerValue="Test2">

          <apex:inputField value="{!pitem.test2__c}" style="width: 80px"/>

          </apex:column>

 <apex:column headerValue="Test3">

          <apex:inputField value="{!pitem.test3__c}" style="width: 80px"/>

          </apex:column>

 

  <apex:column headerValue="Total">

          <apex:inputField value="{!pitem.total__c}" style="width: 80px"/>

          </apex:column>

 

...

...

...

 

after user is changing the values in some of the dataTable input boxes and press a button which is connected to {!quicksave}.

The dataTable updates back to the original values instead of the new ones just saved.

 

Does anyone has an explanation.

 

The only explanation that I might have is that maybe my getter is called before the setter so it updates the table back with the DB values, then the setter is called after the values are already the old ones hence no change in the DB and then the quicksave. later when the getter rebuilds the dataTable again it builds it with the DB values which are the same as the old values.      Could that be it?

(I can see in the Debug that the getter is called twice, one of which is before the quicksave but is it also before the setter updates the DB?)

If that is the case, what can I do?

 

dke01dke01

I am not sure but I think calling actions like quickSave  only work if your using a standardController  or extension  they do not work if you create a custom controller see http://wiki.developerforce.com/index.php/An_Introduction_to_Visualforce

guyr1981guyr1981

Yes, you are right,

it wasn't the problem though...

I actually had a standard controller and my controller was extended controller.

 

In anycase, that wasn't the problem,

the problem was me not getting how setters worked,

but after reading the answer on my previous question,

I understood it and it was fixed.

 

Thanks for the help.