You need to sign in to do that
Don't have an account?
Controller's update call reverts db to old values
Hi,
I have an account controller extension with a save function:
public void save() { baseCtrl.save(); update acct.Contacts; }
a corresponding actionFunction
<apex:actionFunction name="save" action="{!save}" rerender="table"/>
and a pageBlockTable like this:
<apex:pageBlockTable value="{!account.Contacts}" var="con"> <apex:column value="{!con.Name}"/> <apex:column value="{!con.MailingStreet}"/> <apex:column value="{!con.MailingCity}"/> <apex:column value="{!con.Phone}"/> <apex:column value="{!con.Visit_planned__c}"/> <apex:column headerValue="{!$ObjectType.contact.fields.Visit_planned__c.label}"> <apex:inputCheckbox value="{!con.Visit_planned__c}" onclick="rerenderMap(this, '{!con.Id}')"> <apex:actionSupport event="onchange" rerender="table"/> </apex:inputCheckbox> </apex:column> </apex:pageBlockTable>
The JS rerenderMap(cb, id) function renders the contacts in a map and finally calls save() to update the database with the new checkbox value.
I uncheck a checkbox, the (for debug purposes shown) Visit_planned column is updated and the pushpin in the map is removed.
But when the save function is called, the db value of checked is written again and the table is rerendered with a checkmark again!
How can I update the db with the correct value?
Thanks,
Thomas
I think you may have a race condition here - you have defined an onclick handler and an action support. If your onclick handler is executing the save via an actionfunction, do you need the actionsupport?
Bob,
I thought about that but if I remove the actionsupport my table doesn't get updated but the old values are written anyway.
Thomas