Visual Builder

Get Involved. Join the Conversation.

Topic

    Subba Bhamidipati
    How to call long running sync job (ADF BC method) on...Answered
    Topic posted December 18, 2018 by Subba BhamidipatiBronze Medal: 1,250+ Points, tagged REST, SaaS Integration, UI 
    216 Views, 9 Comments
    Title:
    How to call long running sync job (ADF BC method) on page load in VBCS
    Summary:
    Need to call Java method(exposed in AMImpl) on VBCS page load and show busy / loading icon
    Content:

    Hi,

    We have a requirement to process and load batch of invoices from Fusion SaaS (ERP Cloud) before VBCS page loads. This is a functional requirement from business to refresh / sync latest batch of invoices from Fusion SaaS, everytime they launch the UI.

    Previously, we built ADF BC logic and handled this using method call in taks-flow before page renders. Till that method completes we showed ADF busy icon on UI, 

    How can we achieve this same in VBCS UI? If we expose the Java method as REST using ADF BC:

    Would we be able to call the method before VBCS page loads?

    If Yes, how can we show busy / spinning icon till that method completes? 

    Are there any limitation on the amount of time REST API call would wait in VBCS before it times out?

    Any suggestions would be appreciated.

    Thanks,

    Subba

    Best Comment

    Shay Shmeltzer

    I would suggest using an oj-bind-if component to hide the content of the page until the REST call is completed.

    You'll define a page boolean variable that initially is set to false.

    Define the spinner surrounded by one oj-bind-if and the rest of the page surrounded by another.

    Then when you complete the REST call you switch the value of the variable to show/fide as needed.

    More on oj-bind-if here:

    https://blogs.oracle.com/vbcs/dynamic-ui-in-vbcs-applications

     

    Comment

     

    • Shay Shmeltzer

      You can call the method in a vbEnter or a vbBeforeEnter event on your page.

       

      That being said, from a usability aspect maybe a better approach is to get the user into a landing page first - and then have them navigate to the second page and invoke the method in the navigation phase. This will allow you to pop-up a progress bar to the users so they'll know that the system is working on something.

       

    • Subba Bhamidipati

      Thank You Shay for the response. 

      I think in our case, the landing page itself is the list of vendors (search page with default search results) and this is launched from Fusion SaaS home page. 

      Users would like to see all their vendors as soon as they open the custom app instead of seeing another home page or landing page. 

      Is there a way we can show a progress bar or render some content and automate the user-button-click (as if user clicked a button) to execute the action to load data?

      That way user will see something while we load the data behind the scene?

      Please suggest.

       

      • Shay Shmeltzer

        You could add a JS method to your page to show something.

        For example:

          PageModule.prototype.showWait = function(){
           alert("I'm Loading");
          }

        Then, in the vbEnter action use a "Call module function" operation to call your JavaScript code, and then call the action to execute the REST call.

         

    • Subba Bhamidipati

      Thank You Shay! Will try that out.

    • Subba Bhamidipati

      Shay,

      When I tried the above option, JS alert is giving "Ok" button for user to click and as soon as he clicks the page loaded. 

      But, in my case I am trying to call REST API first and til that call completed I need to show a busy icos/spinner on the page. Once the REST API call completes it need to load the page automatically.

      In ADF we used below JS method to achieve this. How can we achieve this in VB?

      function enforcePreventUserInput(evt)

      {

      var popup = AdfPage.PAGE.findComponentByAbsoluteId('p1'); 

      if (popup != null)

      { AdfPage.PAGE.addBusyStateListener(popup,handleBusyState); evt.preventUserInput(); }

      }

      //JavaScript call back handler

      function handleBusyState(evt){

      var popup = AdfPage.PAGE.findComponentByAbsoluteId('p1');

      if(popup!=null){

      if (evt.isBusy()){ popup.show(); }

      else if (popup.isPopupVisible()) { popup.hide();

      AdfPage.PAGE.removeBusyStateListener(popup, handleBusyState); } } }

      • Shay Shmeltzer

        I would suggest using an oj-bind-if component to hide the content of the page until the REST call is completed.

        You'll define a page boolean variable that initially is set to false.

        Define the spinner surrounded by one oj-bind-if and the rest of the page surrounded by another.

        Then when you complete the REST call you switch the value of the variable to show/fide as needed.

        More on oj-bind-if here:

        https://blogs.oracle.com/vbcs/dynamic-ui-in-vbcs-applications

         

    • Subba Bhamidipati

      Thank You Shay!

      I can try that. But one more question, in our case we need to display spinner on page load itself while executing REST API and till it completes. 

      If we are calling REST API on vbEnter phase, how would spinner rendered on page? 

      Also in VBCS, how do we render modal popup for any confirmation messages (Ok/Cancel) ? 

      Thank  you for the help.

    • Subba Bhamidipati

      Thank you Shay for all the help with this. 

      Using <oj-dialog>, <oj-bind-if> along with "Run In Parallel" activity on custom action chain solved our requirement. 

      Now we are able to show progress bar on pageload while REST API is executed in the background and automatically dismiss the dialog as soon as the REST API completes.

      The best of custom action chains(more like process flow steps) is they are REUSABLE. In our case we have same functionality on page load and on-demand button click (user click). I used same custom action chain in both places and it worked like a charm.  

      I love these custom flow action listeners. They are very useful product features. Thank you! Unbelievably we are building visual JS based apps without writing actual JavaScript code!!! Awesome. 

    • Subba Bhamidipati

      For others benifit, below 2 links are useful in how to use JET components in VB 

      https://blogs.oracle.com/vbcs/adding-new-oracle-jet-ui-component-to-visual-builder-cloud-service

      https://blogs.oracle.com/shay/edit-form-in-a-popup-with-oracle-visual-builder