Find your content:

Search form

You are here

ActionPoller & DataTable - Problems

 
Share

I had been seeing strange behavior on a page - and narrowed down the cause of thisodd behavior to the use of an ActionPoller. After doing some research, it seems that using an ActionPoller with a dataTable causes problems.

Below is my code. Does anyone have any suggestions how to refresh this table - but avoid known problems with ActionPoller & DataTable?

Any thoughts would be appreciated. Thanks in advance.

<apex:pageBlock title="Customer Overview"> 
<apex:dataTable value="{!Customers}" var="cust" id="CustList" width="100%" > 
<apex:column > 
<apex:facet name="header"><b>Customer Name</b></apex:facet> 
<apex:commandLink action="{!invokeService}" 
value="{!cust.CustName__c}" rerender="blockA, blockB"> 
<apex:param name="xxx" value="{!cust.id}"/> 
</apex:commandLink> 
</apex:column> 
</apex:dataTable> 
<apex:actionPoller rerender="CustList" interval="5"/> 
</apex:pageBlock> 

I don't have any response on Community Board, and this problems is affecting my org once i cannot use AJAX effect and i cannot improve the user experience.

You can find this topic in : http://boards.developerforce.com/t5/Visualforce-Development/ActionPoller-amp-DataTable-Problems/td-p/253045

I have used all suggestions, including "actionRegion" around "actionPoller". But no success.


Attribution to: Mario Luis Scarpari Citadin

Possible Suggestion/Solution #1

I've seen rerendering problems when using id's of lower level vf elements, have you tried re-rendering the pageBlock ?

Also, the documentation states : (http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_actionPoller.htm)

An <apex:actionPoller> must be within the region it acts upon.

So you should be reRendering the pageBlock rather than the dataTable, as the actionPoller is contained within the pageBlock, not the dataTable.

<apex:pageBlock title="Customer Overview" id ="thePageBlock"> /*DECLARE PAGEBLOCK ID  */
<apex:dataTable value="{!Customers}" var="cust" id="CustList" width="100%" > 

....
<apex:actionPoller rerender="thePageBlock" interval="5"/> /* RERENDER PAGEBLOCK  */

I managed to get the dataTable to rerender okay, by setting reRender = "thePageBlockId" on the actionPoller.


My simplified example (Keeps reducing the number of Contacts displayed)

VF Page :

<apex:page standardController="Account" extensions="AccountExtension">

<apex:form>
<apex:pageBlock id = "thePageBlock">
<apex:dataTable value="{!Contacts}" var="con" id="theDataTable">

<apex:column > 
<apex:facet name="header"><b>Contact Name</b></apex:facet> 
<apex:outputText value="{!con.Name}" /> 
</apex:column>

</apex:dataTable>
<apex:actionPoller interval="5" reRender="thePageBlock" action="{!pollAction}"/>
</apex:pageBlock>
</apex:form>
</apex:page>

Controller :

public class AccountExtension{

Account acc ;
integer contSize = 0;
Contact[] conts ;

public AccountExtension(ApexPages.StandardController acctCon){
    this.acc = (Account) acctCon.getRecord();
    this.query = 'Select Id, Name, Email from Contact where AccountId = \'' + acc.Id + '\'';
}

public String query; 

public Contact[] getContacts(){
if(conts == null){
conts = Database.query(query);
contSize = conts.size();
}
return conts;
}

public PageReference pollAction(){
if(contSize > 0)
conts = Database.query(query + ' LIMIT ' + (--contSize));
return null;
}

}

Attribution to: techtrekker
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/4032

My Block Status

My Block Content