Announcement

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

    batchuploader action on successful commit operation

    Hi Isomorphic ,
    I am using batchuplaoder inside a window. Everything works fine and on clicking commit data gets inserted in DB.
    After successful operation batchuploader shows the below message :
    Click image for larger version  Name:	Capture.PNG Views:	0 Size:	6.3 KB ID:	259511
    My requirement is to close the parent window as soon as user clicks the OK button. I tried to find out but there is no handler in batchuploader to do so. Also there is no way to obtain reference to this box. Can you please suggest How can I close the parent window on click of this OK button?
    Thanks in advance.

    #2
    There's no built-in notification for this dialog closing, but you can figure it out that's closed with the following approach:

    1. put a transformResponse handler on the special "batchUpload" DataSource

    2. when beforeCommit fires, if your transformResponse handler sees a server response that is not an error, then you know the confirmation dialog is showing

    3. use Page.setEvent() to detect the next click and look at the target. If it's a Button with title OK, you know the dialog just got dismissed

    Comment


      #3
      Thanks Isomorphic , I have done the step 1 and 2 and able to detect that confirmation dialog is showing. But not able to do step 3. There is no Page.setEvent() method to capture the mouseclick.

      Comment


        #4
        You posted in the SmartClient forum rather than the SmartGWT forum, hence the SmartClient solution.

        We're looking for a way to do this in SmartGWT, where Page.setEvent() doesn't exist because there are similar core GWT APIs (for example, Event.addNativePreviewHandler).

        However, note that you can call any SmartClient API you may need to via JSNI, so you still have a working solution.

        Comment


          #5
          You haven't reported what version of SGWT that you're using, but if it's SGWT 12.0 or newer, we found an alternate approach for step #3 that doesn't require JSNI, but you'll need to use the next nightly build dated 2019-10-10 as it will have a fix to event handling that allows the sample code to work.

          To try the new approach, add the following definitions in the containing widget:
          Code:
              HandlerRegistration reg;
          
              Dialog getReusableDialog() {
                  Dialog dialog = (Dialog) Canvas.getById("isc_globalWarn");
                  // dialog may not exist if no dialogs have been shown yet
                  if (dialog == null) {
                      SC.say("Creating Reusable Dialog");
                      dialog = getReusableDialog();
                      dialog.clear();
                  }
                  return dialog;
              }
          
              void watchForNoteHide() {
                  if (reg != null) return;
          
                  final Dialog dialog = getReusableDialog();
                  reg = dialog.addVisibilityChangedHandler(new VisibilityChangedHandler() {
                      public void onVisibilityChanged(VisibilityChangedEvent event) {
                          String title = dialog.getTitle();
                          if (!"Note".equals(title) || dialog.isVisible()) return;
          
                          SC.logWarn("*** Dialog hidden!"); // run your code here
          
                          reg.removeHandler();
                          reg = null;
                      }
                  });
              }
          Then in step #2, simply call watchForNoteHide() to start watching for the dialog to be hidden.

          Since this approach relies on heuristics, if your UI is closed through some other means (other than the hook you add to the handler above), you may want to check for reg != null and remove the handler in that case, to ensure it's no longer active.

          Comment

          Working...
          X