3

Having Issue with checkbox onclick and show processing. Problem is that we can have status="mySaveStatus1" associated with but how can we associate status="mySaveStatus1" with <apex:inputCheckbox>? Below is the code:

<apex:column>
    <apex:facet name="header">
        <apex:inputCheckbox title="{!$Label.SelectAllUsersOnThisPage}" value="{!SelectAllUsers}">
            <apex:actionSupport event="onclick" action="{!SelectAll}"/>
        </apex:inputCheckbox>
    </apex:facet>

    <apex:actionStatus id="mySaveStatus1">

        <apex:facet name="stop">
            <apex:inputCheckbox title="{!$Label.SelectUserToBeAdded}" value="{!userWrapper.isSelected}" disabled="{!DisableUserCheckbox && userWrapper.isSelected==false}" >
                <apex:actionsupport event="onchange" action="{!SelectUser}" status="mySaveStatus1" rerender="activateCommandButtons,displayedUserSummary,theUserList">
                    <apex:param name="selectedUserId" value="{!userWrapper.theUser.Id}" />
                </apex:actionsupport>
            </apex:inputCheckbox>
        </apex:facet>

        <apex:facet name="start">
            <img src="{!$Resource.PleaseWait}" />
            <div class="dsPleaseWaitText">
                <apex:outputText value="Please Wait..." />
            </div>
            <apex:inputCheckbox title="{!$Label.SelectUserToBeAdded}" value="{!userWrapper.isSelected}" disabled="true" >
                <apex:actionsupport status="mySaveStatus1" />
            </apex:inputCheckbox>
        </apex:facet>

    </apex:actionStatus>
</apex:column>
5
  • I cleaned up the code formatting a little for you — this site can be a bit tricky when you're starting out! What's the actual issue? It appears you've hooked it up correctly.
    – Matt Lacey
    Sep 5, 2013 at 0:44
  • When the checkbox is clicked then <img src="{!$Resource.PleaseWait}" /> should be executed with the message Please Wait. but it does not work... It works for command buttons when we use <apex:commandButton value="Save Mappings" action="{!save}" status="mySaveStatus1"/> but it throws error when using it with checkbox <apex:inputCheckbox value="{!userWrapper.isSelected}" status="mySaveStatus1"/> so Tried work around (below) but no luck.<apex:inputCheckbox> <apex:actionsupport status="mySaveStatus1"/> </apex:inputCheckbox> .Issue is how to associate status="mySaveStatus1" to checkbox. Sep 5, 2013 at 0:51
  • Doing it with the <apex:actionSupport> should work — though you'll want to add a rerenderparameter as well!
    – Matt Lacey
    Sep 5, 2013 at 0:52
  • @LaceySnr : If I am inside <apex:column> and to enhance the UX, what would be the best way to Disable all the checkboxes (read only) while the request is being processed on one checkbox click. Tried to add value="{!SelectAllUsers}" to <apex:inputCheckbox> for <apex:facet name="start">: <apex:facet name="start"> <apex:outputPanel > <apex:inputCheckbox title="{!$Label.SelectUserToBeAdded}" value="{!SelectAllUsers}" disabled="true" /> Please wait </apex:outputPanel> </apex:facet> Sep 5, 2013 at 20:51
  • 1
    For that you'd want to use javascript events and use script to disable them all. That said, question if you really need to. Even if one is being worked on and you click some of the others, all the requests should go through and work ok.
    – Matt Lacey
    Sep 5, 2013 at 23:29

3 Answers 3

3

This is a complete page which uses a custom checkbox field on the Account object and shows how to use <apex:actionStatus> with <apex:inputCheckbox>.

Things to note that you might be missing are a rerender parameter on the <apex:actionSupport> tag, and an <apex:outputPanel> inside your <apex:facet> tags to group elements together. If you use the code below without the <apex:outputPanel> then it does not render correctly, showing the text but not the checkbox.

<apex:page standardController="Account">
    <apex:form >
        <apex:pageBlock id="theBlock">
            <apex:actionStatus id="theStatus">
                <apex:facet name="start">
                    <apex:outputPanel >
                        <apex:inputCheckbox value="{!Account.Checkbox__c}" disabled="true"/>
                        Please wait...
                    </apex:outputPanel>
                </apex:facet>
                <apex:facet name="stop">
                    <apex:inputCheckbox value="{!Account.Checkbox__c}">
                        <apex:actionSupport event="onclick" action="{!QuickSave}" rerender="theBlock" status="theStatus"/>
                    </apex:inputCheckbox>
                </apex:facet>
            </apex:actionStatus>
        </apex:pageBlock>
    </apex:form>
</apex:page>
2
  • Got no errors in the code or build but the " Please wait..." still does not load. researching and will update the post. Sep 5, 2013 at 1:32
  • Check that your rerendering works if you just use a command button or similar in place. Sometimes you need to specify a hierarchy of IDs to get the right result BlockId.SectionId.SomePanel for instance.
    – Matt Lacey
    Sep 5, 2013 at 1:49
6

Dont make things too complicated :) Here i am using no facets and only one inputCheckbox with some css for styling:

<apex:page standardController="Account">

<style>
.statusStyle {
    background:url(/img/loading.gif) no-repeat 0 0; 
    padding-left:20px; 
    margin-left:10px; 
    padding-bottom:5px; 
}
</style>

<apex:form >
    <apex:pageBlock>
        <apex:outputLabel value="My Checkbox" for="checkBox"/>
        <apex:inputCheckbox value="{!Account.myCheckbox__c}" id="checkBox" styleClass="chk1">
            <apex:actionSupport status="myStatus"
                                event="onchange"
                                reRender="none" 
                                onsubmit="document.getElementsByClassName('chk1')[0].disabled=true;"
                                oncomplete="document.getElementsByClassName('chk1')[0].disabled=false;"/>
        </apex:inputCheckbox>

        <apex:actionStatus id="myStatus" startText="Processing..." 
                           stopText=""   startStyleClass="statusStyle"/>

    </apex:pageBlock>
</apex:form>
</apex:page>

Here is the result:

enter image description here

1
  • Very nice! Just what I was looking for! Jul 17, 2015 at 1:14
0

U can use apex:actionstatus and inside it u can give the image of Please Wait.... the id of action status can we used on the checkbox field it is the simplest approach.

1
  • 1
    Welcome to salesforce.stackexchange Nitesh. Did you want to comment on any of the answers ? Jul 5, 2016 at 11:29

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.