Announcement

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

    RPCManager.cancelQueue() not working

    Hi Isomorphic,

    please see this testcase which shows an annoying bug with RPCManager.cancelQueue(). It seems that canceling does not close the queue. New requests after cancelQueue() are still queued up and not sent directly.
    Click the button "Recreate with cancel" and see that the ListGrid does not load. Using RPCManager.sendQueue() (with an empty queue) instead does solve the problem.
    Tested using FF26, GC50 and v10.1p_2016-04-27.

    BuiltInDS.java:
    Code:
    package com.smartgwt.sample.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.Version;
    import com.smartgwt.client.core.KeyIdentifier;
    import com.smartgwt.client.data.AdvancedCriteria;
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.rpc.RPCManager;
    import com.smartgwt.client.types.OperatorId;
    import com.smartgwt.client.util.Page;
    import com.smartgwt.client.util.PageKeyHandler;
    import com.smartgwt.client.util.SC;
    import com.smartgwt.client.widgets.IButton;
    import com.smartgwt.client.widgets.Window;
    import com.smartgwt.client.widgets.events.ClickEvent;
    import com.smartgwt.client.widgets.events.ClickHandler;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.grid.ListGridField;
    import com.smartgwt.client.widgets.layout.VLayout;
    
    public class BuiltInDS implements EntryPoint {
        public void onModuleLoad() {
            KeyIdentifier debugKey = new KeyIdentifier();
            debugKey.setCtrlKey(true);
            debugKey.setKeyName("D");
    
            Page.registerKey(debugKey, new PageKeyHandler() {
                public void execute(String keyName) {
                    SC.showConsole();
                }
            });
    
            VLayout mainLayout = new VLayout(20);
            mainLayout.setWidth100();
            mainLayout.setHeight100();
    
            IButton recreateCancelBtn = new IButton("Recreate with cancel");
            recreateCancelBtn.setWidth(200);
            recreateCancelBtn.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    recreate("cancel");
                }
            });
            mainLayout.addMember(recreateCancelBtn);
    
            IButton recreateSendBtn = new IButton("Recreate with send");
            recreateSendBtn.setWidth(200);
            recreateSendBtn.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    recreate("send");
                }
            });
            mainLayout.addMember(recreateSendBtn);
            mainLayout.draw();
        }
    
        private void recreate(String mode) {
            Window w = new Window();
            w.setWidth("95%");
            w.setHeight("95%");
            w.setMembersMargin(0);
            w.setModalMaskOpacity(70);
            w.setTitle("cancelQueue() problem with " + Version.getSCVersionNumber());
            w.setShowMinimizeButton(false);
            w.setIsModal(true);
            w.setShowModalMask(true);
            w.centerInPage();
    
            SC.logWarn("Queue open: " + RPCManager.hasCurrentTransactionQueued());
            RPCManager.startQueue();
            SC.logWarn("Queue open: " + RPCManager.hasCurrentTransactionQueued());
            if ("cancel".equals(mode))
                RPCManager.cancelQueue();
            else if ("send".equals(mode))
                RPCManager.sendQueue();
            SC.logWarn("Queue open: " + RPCManager.hasCurrentTransactionQueued());
    
            ListGrid lg = new ListGrid();
            lg.setWidth100();
            lg.setAutoFetchData(false);
            lg.setDataSource(DataSource.get("supplyItem"));
    
            ListGridField itemName = new ListGridField("itemName");
            ListGridField sku = new ListGridField("SKU");
            ListGridField category = new ListGridField("category");
            ListGridField unitCost = new ListGridField("unitCost");
            lg.setFields(itemName, sku, category, unitCost);
    
            w.addItem(lg);
            w.show();
            lg.fetchData(new AdvancedCriteria(sku.getName(), OperatorId.STARTS_WITH, "1"));
        }
    }
    Best regards
    Blama

    #2
    To explain my use case:
    I start a queue and then iterate over the selected records which may or may not end in DSRequests being issued. Therefore it can happen that the queue is empty after I finish iterating.
    In that case I need to cancel and display warnings (which I'd generally prefer to do in the RPCQueueCallback, but this is not called if the queue was empty).

    Best regards
    Blama

    Comment


      #3
      Calling cancelQueue() cancels queued requests but does not turn off queueing. To turn of queuing as well, call startQueue(false).

      Comment


        #4
        Hi Isomorphic,

        that overload is neither javadoc'd in SmartGWT 5.1 nor does it exist in Eclipse auto complete.

        Best regards
        Blama

        Comment


          #5
          It's an optional parameter in SmartClient only.

          Comment


            #6
            We've exposed the requested API in SGWT 5.1p and newer. The change will be in the nightly builds dated 2016-05-05 and beyond.

            Comment


              #7
              Hi Isomorphic,

              thanks for adding. I can see it now.

              Best regards
              Blama

              Comment


                #8
                Hi Isomorphic,

                In the version I downloaded today, RPCManager.startQueue(false) seems to been removed. Was this is purpose? if so - is the recommended procedure in this scenario to now call
                RPCManager.sendQueue() immediately afterwards?

                Code:
                RPCManager.cancelQueue();
                RPCManager.sendQueue();
                Also if possible it would also be helpful to add a note to the documentation for RPCManager.cancelQueue() clarifying that it doesn't end the transaction - and what should be done if this is the behaviour required ?


                SmartClient Version: v11.0p_2017-02-13

                Thanks,

                Mark
                Last edited by mark1; 1 Apr 2017, 13:41. Reason: Code marker incorrect.

                Comment


                  #9
                  Opps, please ignore the above post .. somehow I managed to completely mix up two extracted SmartGWT versions together ... making a complete mess ... one was from this time last year. Sorry for my confusion.

                  Comment


                    #10
                    Hi Isomorphic,

                    I ran into this (non-)issue today again. And even though I knew I solved it once I could not figure out how, immediately.
                    I also think, as mark1 in #8, that cancelQueue() should mention that one will most likely also want to call startQueue(false). Could you add it?

                    Best regards
                    Blama

                    Comment


                      #11
                      We have just added the note to the documentation, as suggested.

                      Thanks,
                      Isomorphic

                      Comment

                      Working...
                      X