Results 1 to 4 of 4

Thread: SubmitCompleteHandler not firing on GET (Download)

  1. #1
    Sencha Premium Member
    Join Date
    Oct 2013
    Location
    Dulles, VA
    Posts
    7

    Default SubmitCompleteHandler not firing on GET (Download)

    So this may be working as designed in which case this is a generic question.

    I have a FormPanel that is hidden on the screen with a hidden field inside of it. Upon submission of this form it goes to a servlet that on a doPost a user is uploading a file and on a doGet the user is downloading a file.

    I force the browser to handle the downloading of the file by setting the content type like so:
    Code:
    response.setContentType("application/force-download")
    Everything performs how I would expect it to except my forms SubmitCompleteHandler doesn't get fired. Is there something that I am missing?

    Client code looks like such:
    Code:
    public FileDownloadWindow(final FileDTO file)    {
            String fileName = file.getName();
            final MessageBox box = new MessageBox("Download File", "");
            final FormPanel form = new FormPanel();
            box.setHideOnButtonClick(false);
            form.setMethod(Method.GET);
            
            final Hidden fileID = new Hidden("uploadid");
            form.add(fileID);
            
            if (fileName != null)
            {
                box.setPredefinedButtons(PredefinedButton.YES, PredefinedButton.NO);
                box.setMessage("Do you want to download " + fileName + "?");
                box.setIcon(MessageBox.ICONS.question());
                box.add(form);
                form.setVisible(false);
                box.getButtonById(PredefinedButton.YES.name()).addSelectHandler(new SelectHandler()
                {
                    public void onSelect(SelectEvent event)
                    {
                        /*
                         * This is where the code for downloading the file goes.
                         */
                        Info.display("getID():", Long.toString(file.getId()));
                        fileID.setValue(Long.toString(file.getId()));
                        form.setAction(GWT.getModuleBaseURL() + "fileOp");
                        form.submit();
                    }
                });
                box.getButtonById(PredefinedButton.NO.name()).addSelectHandler(new SelectHandler()
                {
                    public void onSelect(SelectEvent event)
                    {
                        box.hide();
                    }
                });
            }
            else
            {
                box.setPredefinedButtons(PredefinedButton.OK);
                box.setMessage("Please select a file to download.");
                box.setIcon(MessageBox.ICONS.warning());
                box.getButtonById(PredefinedButton.OK.name()).addSelectHandler(new SelectHandler()
                {
                    public void onSelect(SelectEvent event)
                    {
                        box.hide();
                    }
                });
    
    
            }
    
    
            box.show();
            form.addSubmitCompleteHandler(new SubmitCompleteHandler()
            {
                public void onSubmitComplete(SubmitCompleteEvent event)
                {
                    box.hide();
                }
            });
    }

  2. #2
    Sencha Sr Product Manager
    Join Date
    Jan 2012
    Location
    Arlington, WA
    Posts
    1,178
    Answers
    12

    Default

    1. I would double check the imports to be sure they are gxt types.
    Code:
    import com.sencha.gxt.widget.core.client.event.SubmitCompleteEvent;
    import com.sencha.gxt.widget.core.client.event.SubmitCompleteEvent.SubmitCompleteHandler;
    2. Possibly move the handler to earlier, although it looks correct.

    Brandon

  3. #3
    Sencha Premium Member
    Join Date
    Oct 2013
    Location
    Dulles, VA
    Posts
    7

    Default

    Brandon,

    Thank you for your response! I verified that the imports are correct and they match the ones that you have above.

    Is it possible that the form just doesn't get a response when the content type is "application/force-download"? Maybe the browser catches it first and never propagates it?

  4. #4
    Sencha Sr Product Manager
    Join Date
    Jan 2012
    Location
    Arlington, WA
    Posts
    1,178
    Answers
    12

    Default

    Could you provide a test case that replicates the issue? This will make sure I'm on the same page and I can verify the issue. Looks like it could be a bug.

    http://docs.sencha.com/gxt-guides/3/.../TestCase.html > more on creating a test case.

    Thanks,
    Brandon

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •