+ Start a Discussion
bozotheclownbozotheclown 

ActionPoller & DataTable - Problems

Hello. 

 

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>

 

jwetzlerjwetzler

What are the "known problems" you're referring to?  You don't even specify what your problems are.

 

If you're seeing anything weird it would probably be because you're refreshing the container that holds the actionPoller.  If your actionPoller keeps getting refreshed it's probably going to throw off your interval.  Why do you need to have the poller inside of the table you are trying to refresh?

bozotheclownbozotheclown

Thanks for the quick response!  My "known problems" comment was based on some quick web research that I did on actionpollers and datatables.  I even noticed a comment in the documentation that did not endorse using actionpollers with enhanced lists.

 

As for my specific issue, I am displaying a list of customers that changes on a constant basis (so that is why I need the actionpoller).  This list uses a commandLink to populate items in a separate pageBlock called "CustDetailInput". This is simply a related list for whatever customer record is clicked.

 

I am able to enter these customer interaction records without problems most of the time.  However, let's say I do the following....1) click on a customer name; 2) enter two interaction records;  3) then press the "Submit Interactions" button;  4) then click on the same customer name in the customer list...and repeat this sequence four times.

 

The problem with the above is that I am seeing errors on the fifth or sizth above cycle.  My investigation has shown me that the ID of the Customer__c record is not properly passed on this fifth or sixth cycle - instead it is blank.  I am confident that the actionPoller is causing this because all is fine when I remove the actionpoller line of code (and I am able to do many cycles of the above).

 

Any thoughts would be greatly appreciated...also, to answer a question of yours, my understanding is that the the poller is outside of the table.

 

Thanks much.

 

 

<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>

<apex:commandButton action="{!Detailsinput}" value="Enter Interaction" rerender="CustDetailInput, OtherBlock"/>


<apex:outputPanel id="CustDetailInput">
<apex:pageBlock title="Customer Details" rendered="{!NOT(ISNULL(showCustDetailInput))}">
<apex:pageBlockButtons location="top">
<apex:commandButton value="Submit Interactions" action="{!saveCustDetails}" rerender="OtherBlock, CustDetailInput, blockB, CustList"/>
</apex:pageBlockButtons>
<apex:dataTable columns="2" value="{!detailEntry}" var="a" width="100%">
<apex:column > 
<b>Interaction</b>
<apex:inputField value="{!a.Interaction__c}"/> 
</apex:column>
<apex:column > 
<b>Notes</b>
<apex:inputField value="{!a.Notes__c}"/> 
</apex:column>
<apex:facet name="header">            
<apex:commandButton value="Add Interaction Item" action="{!addIntItem}"/> 

 

jwetzlerjwetzler

Oh I'm sorry your actionPoller is outside of the dataTable, I misread.

 

Okay so now what I'm concerned about is the fact that you have an actionPoller that is updating your page while you're populating inputs.  I think the actionPoller is going to submit everything in your form so if you're in the middle of filling out some inputs you might get it submitted prematurely.  Try putting an apex:actionRegion around your actionPoller component and see if that helps.  It will limit what gets submitted to the server (in this case, it won't submit anything) when the poller fires.

bozotheclownbozotheclown

Appreciate that.  Unfortunately, I am experiencing the same behavior.  I will play around with the actionregion command to see if it or a related command will help. 

 

One FYI.  The form I am filling out is outside of the pageBlock being updated by the actionpoller.  The stange thing here is that the ID that is needed from the dataTable being refreshed is (for some reason) returning as a blank value every few cycles.

 

Thanks for the help.

marioluiscitadinmarioluiscitadin

Hi Guys,

 

I am Experiencing the same bug/problem.

I have tried use "enabled=false" attributte of apex:actionPoller when i click in a button into my datatable, but it happens the same problem, the actionPoller don't disable.

 

Did you get a Solution for your case?

 

 

Thanks a Lot,

Mario Citadin

 

 

 

bozotheclownbozotheclown

Mario-

 

Hello.  I actually never totally resolved it.  You can try an ActionRegion...but (for me) the behavior still did not seem to always act properly..

marioluiscitadinmarioluiscitadin

Thanks,

 

Yes i have  used actionRegion around actionPoller, but no success, i continue with the problem.

 

I have notice if i remove "rerender" attribute of commandbutton all works fine. So, the problem i think is in Ajax Queue, But i don't have a solution yet :(

 

 

Best Regards,

Mario Citadin

calvin_nrcalvin_nr

Any update to this problem guys? Did you guys manage to find a solution.

khushbukhushbu

Hello , 

 

I want to refresh my grid on DML events.

I am inserting records manually and I want to refresh my grid automatically.

Please help me.

M a fresher in salesfoI have used actionPoller.

But i think I must write some code for refreshing my grid.

 

I am confused.