0

I have two-page references, on the first page I am performing a DML operation which takes time around 1,2 seconds, and then it goes to the next page.

What I want is a loading symbol for those 2 seconds, When I try to add spinner in the VF page, It works fine but it won't be redirected to the next page. Does anyone have the solution?

Here is the VF page code.

<apex:actionStatus id="pageStatus">
     <apex:facet name="start">
           <apex:outputPanel >
                 <img src="/img/loading32.gif" width="25" height="25" />
                 <apex:outputLabel value="Loading..."/>
           </apex:outputPanel>
    </apex:facet>
</apex:actionStatus>

<apex:commandButton action="{!assignLoans}" status="pageStatus" value="Assign Loans" styleClass="slds-button slds-button--brand" disabled="false" style=" margin-right:7px;"/>

And Here is the Apex.

// Assigning Loans
public Pagereference assignLoans(){
    drawdownFunderData();
    assignDrawDown();
    Pagereference redirectedPage = new Pagereference('/apex/FF_Report');
    // redirectedPage.setRedirect(true);
    return redirectedPage;
}

Here in apex it performs the action till assignDrawDown(); But doesn't excicute the PageReferance.

It shows the spinner till Loans are assigned, But doesn't redirect to next page.

  • Try adding reRender="" to your commandbutton, see if that fixes it. – sfdcfox Feb 1 at 13:32
  • Yes, I have tried that. It's not working ! – Akshay Chauhan Feb 1 at 13:51
0

Working for a long time on this issue, I came to know that there is no way to perform an Action function and render the vf page to another page.

So I had to make them in one page and give them div tags for rerender.

Thank you @sfdcfox for your suggestion, It worked for me.

If anyone is having the same problem, here is the sample code.

        <apex:outputPanel id="op1">
              <apex:commandButton action="{!nextPage}" value="Next Page" status="status" rerender="op1,op2"/>
        </apex:outputPanel>
        <apex:actionStatus id="status" title="Please Wait">
              <apex:facet name="start">
                    <div class="slds-spinner_container">
                         <div role="status" class="slds-spinner slds-spinner--medium slds-spinner--brand">
                                <span class="slds-assistive-text">Loading</span>
                                <div class="slds-spinner__dot-a"></div>
                                <div class="slds-spinner__dot-b"></div>
                          </div>
                          <div class="slds-container--fluid slds-m-top--large">
                                <div class="slds-grid slds-grid--align-center slds-text-heading--small" style="margin-top:30%;">
                                      Assigning Loans, please wait ...
                                </div>
                          </div>
                     </div>
               </apex:facet>
        </apex:actionStatus>
        <apex:outputPanel id="op2">
              This second page will be displayed...
        </apex:outputPanel>

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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