4

I am trying to disable my button from being pressed twice. When this happens, a self-registration user is only created once - but multiple 'account' records are created (person accounts) for each time I was able to speed-click the sign up page.

I previously was using a facet to successfully disable the button while the apex was doing its magic. However, now I have had a change in the process and have to do a second action. So, I added in actionFunction to daisy-chain them together. The issue is now I am having the 'duplicates' when I click multiple times. Is there a way for me to do this with the actionFunction?

What is the proper way to go about disabling this button from being clicked more than once in this situation? Currently I can set it to disabled, but I can't get it to un-disable after the actions are all finished... thoughts?

<apex:commandButton  status="SaveButtonStatus"
                     id="SignUp"
                     onclick="startRegistration_JS();return false;" 
                     value="Sign Up" 
                     reRender="result" />

[action #1]
<apex:actionFunction action="{!startRequest}" 
                     name="startRequest_JS" 
                     reRender="result" 
                     oncomplete="startRegistration_JS() ;"/>
[action #2]        
<apex:actionFunction action="{!startRegistration}" 
                     name="startRegistration_JS" 
                     reRender="result" 
                     oncomplete="status='false';" />
5

One way use action status. Display loading symbol unit your process is not completed.

<apex:actionFunction action="{!startRequest}" 
                     name="startRequest_JS" 
                     reRender="result" 
                     oncomplete="startRegistration_JS() ;"
                     status="counterStatus"/>

<apex:actionFunction action="{!startRegistration}" 
                     name="startRegistration_JS" 
                     reRender="result" 
                     oncomplete="status='false';" 
                     status="counterStatus"/>

<apex:actionstatus id="counterStatus">
        <apex:facet name="start">
            <div class="waitingSearchDiv" id="el_loading" style="background-color: #fbfbfb; height:100%;opacity:0.65;width:100%;">
                <div class="waitingHolder" style="top: 100px; width: 91px;">
                <img class="waitingImage" src="/auraFW/resources/aura/images/spinner.gif" title="Please Wait..." />
                <span class="waitingDescription">Loading...</span>
                </div>
            </div>
        </apex:facet>
    </apex:actionstatus>

Another way

Below code will work as standard buttons. like when you click on button it will display processing..

<apex:pageBlockButtons >
    <apex:actionStatus id="mySaveStatus1">
        <apex:facet name="stop">
            <apex:commandButton action="{!save}" status="mySaveStatus1" value="Save" disabled="false" rerender="mySaveStatus1"/>
        </apex:facet>
        <apex:facet name="start">
            <apex:commandButton action="{!save}" status="mySaveStatus1" value="Saving..." disabled="true"/> 
        </apex:facet>
    </apex:actionStatus>
    <apex:actionStatus id="myCancelStatus1">
        <apex:facet name="stop">
            <apex:commandButton action="{!cancel}" status="myCancelStatus1" value="Cancel" disabled="false" rerender="myCancelStatus1"/>
        </apex:facet>
        <apex:facet name="start">
            <apex:commandButton action="{!cancel}" status="myCancelStatus1" value="Processing..." disabled="true"/>
        </apex:facet>
    </apex:actionStatus>
</apex:pageBlockButtons>

enter image description here

2

You can use block UI and action status to solve this problem.

<apex:actionStatus id="statusSaveTrip" stopText="">
            <apex:facet name="start">
                <div id="blockUIDiv" >
                    <div class="blockUI blockOverlay" style="z-index: 1000; border: none; margin: 0px; padding: 0px; width: 100%; height: 100%; top: 0px; left: 0px; opacity: 0.6; cursor: wait; position: fixed; background-color: rgb(0, 0, 0);"></div>
                    <div class="blockUI blockMsg blockPage" style="z-index: 1011; position: fixed; padding: 15px; margin: 0px; width: 30%; top: 40%; left: 35%; text-align: center; color: rgb(0, 0, 0); border: none; cursor: wait; border-radius: 10px; opacity: 0.9; background-color: rgb(255, 255, 255);"><img src="/img/loading32.gif"/><br/><h1>Please Wait....</h1></div>
                </div>
            </apex:facet>
        </apex:actionStatus>

Try this code .it will block your screen and you don't need any external Jquery as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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