1

Feel I am missing something obvious...I have a page with a button that calls a web service, then re-renders an output panel to show the results

EDIT - seems to be an issue with PageBlockButtons? Just tried this is a new org and same behavior...

This works fine:

<apex:page id="newMembertoQ" controller="SamplePageController">
<apex:form >
<apex:pageBlock id="newMembertoQPageBlock"> 
<!-- <apex:pageBlockButtons  id="newMembertoQPageBlockButtons"> -->
<apex:commandButton id="newMembertoQPageBlockButtonSubmittoQ2" action="{!submittoQ}" value="Submit to Q No Status"/>
    <apex:actionStatus id="submitMembertoQ">

             <apex:facet name="start">
                 <apex:outputPanel >
                       <apex:image value="/img/loading32.gif" style="height: 15px;"/>
                       <apex:commandButton value="Creating Q Record..." disabled="true"/>
                   </apex:outputPanel>
            </apex:facet>

            <apex:facet name="stop">
            <apex:commandButton action="{!submittoQ}" value="Create in Q" status="submitMembertoQ"/>
            </apex:facet>

    </apex:actionStatus>
    <!-- </apex:pageBlockButtons> -->
<apex:outputText value="{!sParams}"></apex:outputText>
</apex:pageBlock>
</apex:form>
</apex:page>

Controller:

public with sharing class SamplePageController {

public Integer sParams {get;set;}

    public SamplePageController () {
        sParams = 0;

    }

    public PageReference submittoQ () {
    sParams ++;
    return null;
    }

    }

But if you remove the comments to include the pageblockbuttons, the actionstatus version of the button increments the sParams by 2 instead on 1...which I do not understand...!

2 Answers 2

4

Like what BritishBoyInDC wrote, this is restricted to pageBlockButtons. As a workaround, if you add location="top" (or bottom) to your pageBlockButtons element, the event will only fire once.


        <apex:pageBlockButtons location="top">
            <apex:actionStatus id="commentSave">
                <apex:facet name="start">
                    <apex:commandButton value="Saving..." disabled="true"/>
                </apex:facet>
                <apex:facet name="stop">
                    <apex:commandButton action="{!doSave}" value="Save" reRender="commentBlock" status="commentSave"/>
                </apex:facet>
            </apex:actionStatus>
            <apex:actionStatus id="commentNew">
                <apex:facet name="stop">
                    <apex:outputPanel>
                        <apex:commandButton action="{!addComment}" value="New" reRender="commentTable" status="commentNew"/>
                    </apex:outputPanel>
                </apex:facet>
                <apex:facet name="start">
                    <apex:outputPanel>
                        <apex:commandButton disabled="true" value="Creating..."/>
                    </apex:outputPanel>
                </apex:facet>
            </apex:actionStatus>
        </apex:pageBlockButtons>
1

You shouldn't call your status on the commandbutton in the start method, you only need on the stop :

<apex:actionStatus id="submittoQStatus">
        <apex:facet name="start">
             <apex:outputPanel >
                   <apex:image value="/img/loading32.gif" style="height: 15px;"/>
                   <apex:commandButton value="Creating Person Record..." disabled="true"/>
               </apex:outputPanel>
           </apex:facet>

         <apex:facet name="stop">
        <apex:outputPanel>
        <apex:commandButton id="SubmittoQ2" action="{!submittoQ}" value="Submit to Q" reRender="xmldata,personResult" status="submittoQStatus"/>
         </apex:outputPanel>
         </apex:facet>

</apex:actionStatus>
4
  • Sadly, no joy - still fires twice... Commented Feb 28, 2014 at 0:26
  • Mm! Not too sure, I copied your code and it's never fired twice for me.
    – brovasi
    Commented Feb 28, 2014 at 0:34
  • ah - good to know - I'll dig more on my end then...thanks! Commented Feb 28, 2014 at 0:37
  • I can't see that this change would make any difference, as the status is just an attribute on a disabled commandbutton. The status only comes into play when the commandbutton is clicked, which the disabled attribute will stop. Commented Feb 28, 2014 at 8:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .