I have found a strange behaviour and I can't find why does it happening. I have custom object Test2_c with custom text field Status_c. I want to change it's status asynchronously, so I prepare a VF page:
<apex:page standardController="Test2__c" extensions="test2ExtController">
<apex:form id="someform">
<apex:commandButton action="{!statusClose}" value="Close"
rendered="{!Test2__c.Status__c == 'Open'}" rerender="someform"/>
<apex:commandButton action="{!statusOpen}" value="Reopen"
rendered="{!Test2__c.Status__c == 'Closed'}" rerender="someform" />
<apex:detail id="detail"/>
</apex:form>
</apex:page>
and controller extension:
public class test2ExtController {
private final Apexpages.Standardcontroller stdController ;
public void statusClose() {
SObject obj = stdController.getRecord();
obj.put('Status__c', 'Closed');
update obj;
}
public void statusOpen() {
SObject obj = stdController.getRecord();
obj.put('Status__c', 'Open');
update obj;
}
public test2ExtController(ApexPages.StandardController controller) {
stdController = controller;
}
}
Now strange things are happening:
- I click the button -> status is updated, buttons are rerendered, BUT
<apex:details>
remain the same - I click the second button -> status is updated, buttons are rerendered AND
<apex:details>
are rerendered but in a WRONG way. It reflect changes made in step 1!!!
From this behaviour i conclude, that <apex:details>
IS rerendered but BEFORE the object is updated and buttons are rerendered AFTER object is updated. Why?
Am I making something wrong? How can I get details refreshed after async update call?