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

When I call a actionFunction multiple times at once, the controller looses some values

I'm trying to put a commandButton in each row in pageBlockTable. Those buttons call the same function ("Update"), but different parameter. The function updates the status in the row by using the given parameter to determine which row should be updated.


Also there is a button "refresh" to reRender the entire pageBlockTable. The statuses are updated by controller, so reRendering should not loose any data (status).


Initial status is "new" when you click the "update" button, the status in the row will change to the curren time.

After changing all status from "new" to time, click "refresh". Nothing should change.


When you click "Update"s one by one, refresh doesn't change anything.

However, when you click very quickly without waiting the end of each actionFucntion (you can do that because it's asychronous), the refresh loose some values from the page and never come back!!!


That's very weird because all values are stored in the controller so that page refresh shouldn't matter.




Is this because Controller is not stateless and the state is controlled (managed) by browser? Is that the reason why some concurrent processes conflict and loose the values?



And, what could be the workaround? disable buttons in onStart and enable them onStop?


Thank you in advance.






[Initial page]


Initial page

[Change status from 'new' to the time]

[After refresh, some values are lost !!]

some values are lost



 [VF page]

<apex:page controller="MultiThreadTestController">
<apex:form >
<apex:pageBlock id="pageBlock">
<apex:commandButton value="refresh" action="{!refresh}" rerender="pageBlock"/>
<apex:pageBlockTable value="{!Items}" var="item">
<apex:column >
<apex:facet name="header">Button</apex:facet>
<apex:commandButton value="Update" action="{!updateStatus}" reRender="status">
<apex:param name="selectedItem" value="{!}" assignTo="{!selectedItem}"/>
<apex:column >
<apex:facet name="header">Status</apex:facet>
<apex:outputText value="{!item.status}" id="status"/>


public class MultiThreadTestController {
class Item {
public string name {get; set;}
public string status {get; set;}
public Item(string name, string status){ = name; this.status = status;}

public Item[] items {set; get;}
public string selectedItem {get; set;}

public MultiThreadTestController (){
items = new List<Item>();
for(integer i=1;i<=5;i++) items.add(new Item(''+i, 'New'));

public PageReference refresh() {return null;}

public PageReference updateStatus() {
Item selected = null;
for(Item i : items){if( == selectedItem){selected = i;break;}}
if(selected == null) return null;
selected.status = selectedItem + ' - ' +;
// wait for a while
integer a = 0;
for(integer i=0;i<10000;i++) a+=i;
return null;









Ron HessRon Hess

Your idea, 

 disable buttons in onStart and enable them onStop?


 is a good solution.


not sure what could cause the page to never come back.



Thank you for your reply.


> not sure what could cause the page to never come back.

Sorry, my explanation was  poor.

Page comes back, but some values are lost (and the value never comes back).


I'd like to know why some of values are lost. Any idea?


Thank you,



Message Edited by ThomasTT on 03-27-2009 04:47 PM