+ Start a Discussion
Jyosi jyosiJyosi jyosi 

Action Support until the redirecting of the page

Hello Everyone,
I have page when user clicks verify i insert the record and make a callout. In executeWS() i call another call where we update the response from External system. It's get updated and everything works. executeWS() code is below. when i verify i get the status bar ,but the  status bar won't appear on the page until the page gets redirect.
I need to keep the status bar working until the pages the get loaded successfully after the redirect. I need to show user please wait i am updating   the values and getting the page back for the result.

 
<apex:commandButton value="Save As Draft " action="{!saveSample}"  reRender="pgBlckId,table" status="actStatusId"/>
             
             <apex:commandButton value="Verify" action="{!saveSample}" oncomplete="executeWS()" status="actStatusId"  reRender="isSF1"/>
             <apex:actionStatus id="actStatusId" rendered="true" >
             <apex:facet name="start" >
                  <apex:actionFunction name="executeWS" action="{!executeWS}" >
                  <div class="waitingSearchDiv" id="el_loading" style="background-color: #fbfbfb;
                       height: 100%;opacity:0.65;width:100%;"> 
                    <div class="waitingHolder" style="top: 74.2px; width: 91px;">
                        <img class="waitingImage" src="/img/loading.gif" title="Please Wait..." />
                        <span class="waitingDescription">Please Wait...</span>
                    </div>
                </div>
                 </apex:actionFunction>
                </apex:facet>
            </apex:actionStatus>
public PageReference executeWS(){
    bsubmit =validateUserInputs(true);
    system.debug('validateUserInputs ==== '+validateUserInputs(bsubmit));
   if(bsubmit!=true) 
   {
           try{
             if(OrderNumber.get(sampleRecord.Id)==null)
             {
               callout.processSampleOrderRequestCreate(this,samplerecord.Id);
              
               PageRedirect = new PageReference('/apex/XXX?Id='+sampleRecord.Id+'');
               PageRedirect.setRedirect(true);
              }else{
               callout.processSampleOrderChangeRequest(this,samplerecord.Id);
               PageRedirect = new PageReference('/apex/XXX?Id='+sampleRecord.Id+'');
               PageRedirect.setRedirect(true);
              }
        }catch(Exception e)
             {
               system.debug('Exception === '+e.getMessage()); 
             }
           
      }
       return PageRedirect;
   }

Thanks for the help.

Regards,
Jyo
 
PawanKumarPawanKumar
Please try below code.

----------------------------------------------------

public PageReference executeWS() {
 bsubmit = validateUserInputs(true);
 system.debug('validateUserInputs ==== ' + validateUserInputs(bsubmit));
 if (bsubmit != true) {
  try {
   if (OrderNumber.get(sampleRecord.Id) == null) {
    callout.processSampleOrderRequestCreate(this, samplerecord.Id);

    PageRedirect = new PageReference('/apex/XXX?Id=' + sampleRecord.Id + '');
    //PageRedirect.setRedirect(true);
   } else {
    callout.processSampleOrderChangeRequest(this, samplerecord.Id);
    PageRedirect = new PageReference('/apex/XXX?Id=' + sampleRecord.Id + '');
    //PageRedirect.setRedirect(true);
   }
  } catch (Exception e) {
   system.debug('Exception === ' + e.getMessage());
  }

 }
 return PageRedirect;
}

-------------------------
Regards,
Pawan Kumar
Jyosi jyosiJyosi jyosi
Hello Pawan,

It wont pull the updated values and still the pages continues to spin with on the browser.

Thanks

Regards,
Jyo