Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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.

share|improve this question
1  
What is this 'odd behaviour' that you're experiencing? Could you please provide some details. –  techtrekker Nov 5 '12 at 0:02

1 Answer 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;
}

}
share|improve this answer
    
Thanks for your feedback. But i think you did not understand my problem. Let me explain: The problem occurs when i click on button that is into datatable. If you see, that button has a apex:param XXX with value={!cust.id}. So, when actionPoller is enabled and i click on that button, the param is not sent to server side, XXX=null on controller. But if i disable the actionPoller, the param is sent finely to server XXX=0010000000xAESr. This is very strange, because i use apex:actionRegion around actionPoller. –  Mario Luis Scarpari Citadin Nov 5 '12 at 18:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.