Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    How to block user actions until a set of DSRequests complete.

    I have a few data sources that are related in standard header/detail pattern. In this case the header has a few different sets of details. The header records are listed in a ListGrid and when the user selects a ListGrid record we open a new window with multiple tabs. One tab shows a form with fields from the header record (via form.editRecord(theSelectedListGridRecord)) . Other tabs show additional ListGrids that are filled with the various details.

    When the window first opens, the user can start editing the header form fields while the detail ListGrids are still waiting for data to arrive. But some of the methods that are triggered by the users changes to the header fields need to reference the data in the detail ListGrids.

    How do I keep the "Contacting server" dialog in place until all of the ListGrids are populated?

    #2
    Just combine them all into a queue with RPCManager.startQueue().

    Comment


      #3
      I tried that, but the window and form are still displayed and is usable before the ListGrids on the other tabs finish loading.
      Code:
      RPCManager.setShowPrompt(true);
      RPCManager.setPromptStyle(PromptStyle.DIALOG);
      RPCManager.startQueue();
      // These methods file the ListGrids on the other tabs.
      getTermsAndConditions();
      getLabelingConditions();
      customizePoHeaderForms();
      
      RPCManager.sendQueue();
      poHeaderEditWindow.show();
      It seems like I would need a callback on the sendQueue in which I would put the poHeaderEditWindow.show() call.

      Comment


        #4
        Take a look in your RPC Tab to see if those requests are actually being sent as a queue. Possibly they are not because you are manually calling sendQueue() elsewhere. Alternatively, possibly you are manually dismissing the prompt with SC.hidePrompt().

        Comment


          #5
          I'm not manually calling sendQueue() or hidePrompt() anywhere else. I can see in the RPC tab that the first five requests are sent as a queue, 3 ListGrid.fetchData() calls and 2 calls to populate SelectItems. But then there are 4 more DSRequests from another ListGrid, SelectItem and two calls to DataSource.fetchData() in that order, and those are not part of any queue.

          What would cause the queue to be sent before my explicit call to sendQueue()?

          Comment


            #6
            I realize now that the second set of requests are actually triggered in a callback from the first request. That's why they aren't part of the same queue.

            What is the recommended pattern in this case? I need to wait for a fetch to complete and then do another fetch, and only when that second fetch completes can the user interaction start.

            Comment


              #7
              If you can't make it all into one network turnaround (the best solution), you can manually call SC.showPrompt() at the beginning and SC.hidePrompt() at the end.

              Comment

              Working...
              X