Friday, May 6, 2016

Action Status is not working for Command Buttons or Ajax Functions

Action Status:
   Action Status is an Ajax function which will be used to show the status of an action that is happening in background.

Example

1.Click on Button just showing like an Loading Image
2.Click on any command link showing some status Please wait loading...

Issue:
Recently I come across an issue like when I click on command button I want to show some status Image.I have implemented status message (Using Preloaders)and I'm passing same to command button but still it's not working.

Sample Page
 <apex:page standardController="Account" extenstions="AccountEtn">  
     <apex:form id="formId">  
       <apex:actionstatus id="attachingStatus" >  
          <apex:facet name="start">  
              <div class="waitingSearchDiv" id="el_loading" style="background-color: white; height:90%;opacity:0.65;width:100%;">  
                  <div class="waitingHolder" >  
                       <img class="waitingImage" src="{!$Resource.Loading}" title="Please Wait..." />  
                          <font color="Red"><b>Please wait we are loading....</b></font>   
                  </div>  
              </div>  
          </apex:facet>  
       </apex:actionstatus>  
       <apex:pageBlock id="pbid1" >  
            <apex:pageBlockButtons >  
                <apex:commandButton value="Save" action="{!save}" id="saveButton" status="attachingStatus" />  
                 <apex:commandButton value="Cancel" action="{!cance}" id="cancelButton" status="attachingStatus" />  
            </apex:pageBlockButtons>  
        </apex:pageBlock>  
      </apex:form>  
 </apex:page>  

Above sample code I have written in my page and when I click on any command buttons nothing is happening..It's not showing any status it's simply executing the logic .

Reason for the Issue

Some times if your command button not specifying any reRender attribute in your command button it will not show action status

Work Around Solution

Please include the reRender attrbute as part of your command button then it will work.

 <apex:page standardController="Account" extenstions="AccountEtn">  
     <apex:form id="formId">  
       <apex:actionstatus id="attachingStatus" >  
          <apex:facet name="start">  
              <div class="waitingSearchDiv" id="el_loading" style="background-color: white; height:90%;opacity:0.65;width:100%;">  
                  <div class="waitingHolder" >  
                       <img class="waitingImage" src="{!$Resource.Loading}" title="Please Wait..." />  
                          <font color="Red"><b>Please wait we are loading....</b></font>   
                  </div>  
              </div>  
          </apex:facet>  
       </apex:actionstatus>  
       <apex:pageBlock id="pbid1" >  
            <apex:pageBlockButtons >  
               <apex:commandButton reRender="pbid1" value="Save" action="{!save}" id="saveButton" status="attachingStatus" />  
               <apex:commandButton reRender="pbid1" value="Cancel" action="{!cance}" id="cancelButton" status="attachingStatus" />  
            </apex:pageBlockButtons>  
        </apex:pageBlock>  
      </apex:form>  
 </apex:page>  

Thanks for Visiting.....Enjoy!


No comments:

Post a Comment