You need to sign in to do that
Don't have an account?
Problem using actionPoller to show a spinner and an error message
Hi all,
this is frustrating me, would appreciate any suggestions.
I have a VF controller that does an http callout and the VF page shows a spinner while this is happening - no problem.
However it sometimes happens that the callout fails and I want to show an error message before redirecting back to an Account detail page.
For some reason the error message is never shown.
Debug logs show me that I am executing the code as expected and the values of the error message and the flags are as expected.
The utility calls below check and clear a static boolean I use to indicate the callout state.
Code follows - thanks in advance for your help
VF page
<apex:form >
<apex:actionPoller action="{!checkStatus}" interval="5" reRender="theSpinnerPanel, theErrorMessagePanel" />
<apex:outputPanel id="theSpinnerPanel" rendered="{!NOT(mp_bInError)}" >
<apex:panelGrid columns="1" border="0" rules="none" cellspacing="2" cellpadding="2" columnClasses="colaligncenter" >
<apex:image value="{!$Resource.Sqware_Peg_Searching_animation}" />
</apex:panelGrid>
</apex:outputPanel>
<apex:outputPanel id="theErrorMessagePanel" rendered="{!(mp_bInError)}" >
<apex:outputText value="{!mp_strErrorMessage}" styleClass="messageErrorText" />
</apex:outputPanel>
</apex:form>
Controller
public pageReference checkStatus()
{
// Check to see if we have finished
if (SP_Utilities.CalloutInProgress())
{
return null;
}
if (m_bErrorMessageDisplayed)
{
return doReturn();
}
if (mp_bInError)
{
m_bErrorMessageDisplayed = true;
return null;
}
// Check the callout was successful
if (m_liFootprintCasestoInsert.isEmpty())
{
mp_strErrorMessage = '*** Refresh failed ***';
SP_Utilities.clearCalloutInProgress();
mp_bInError = true;
return null;
}
<code for successful callout processing follows>
This is because you are trying to rerender an outputpanel that wasn't rendered in the first place.
I wrote a blog post explaining this and how to work around it at:
http://bobbuzzard.blogspot.com/2011/02/visualforce-re-rendering-woes.html
All Answers
This is because you are trying to rerender an outputpanel that wasn't rendered in the first place.
I wrote a blog post explaining this and how to work around it at:
http://bobbuzzard.blogspot.com/2011/02/visualforce-re-rendering-woes.html
Awesome, many thanks Bob