1

I've created a javascript method from Wicket which will reload a panel:

Behavior behave = new AbstractDefaultAjaxBehavior() {
        @Override
        protected void respond(AjaxRequestTarget target) {
            target.appendJavaScript(JavascriptUtils.functionCallback(INIT_JQUERY_UPLOAD_JS));
            target.add(photosetsContainer);
        }

        /**
         * Creates a javascript method: reloadImagesPanel(duplicateImagesList) and renders it in head section of
         * html. This method is called after the user selects images using uploader.
         */
        @Override
        public void renderHead(Component component, IHeaderResponse response) {
            super.renderHead(component, response);
            CharSequence callback = getCallbackScript();
            String reloadImagesJs = JavascriptUtils.function(RELOAD_IMAGES_PANEL_JS, callback.toString());
            response.render(JavaScriptHeaderItem.forScript(reloadImagesJs, null));
        }

    };
    add(behave);

I'm using jquery.fileupload to upload some images:

$('.fileupload').fileupload({
  dataType: 'json',
  done: function (e, data) {
    reloadImagesPanel();
  },
  fail: function (e, data) {
    alert("There was a problem while uploading, please try again!");
  },
  progress: function (e, data) {
    $(e.target).closest('.multipleUploadButtonContainer').find('.imagesUploadSpinner').spin(SPINNER_MIN_OPTS);
  }
});

RELOAD_IMAGES_PANEL_JS = reloadImagesPanel

So, when I'm uploading the images, they are moved to the corresponding folder, the reloadImagesPanel() is called, but there is no GET request in the Console Network Tab which tells me that the respond method from the server-side was done and, of course, the panel was reloaded.

This is what I'm expecting to see:

enter image description here

No errors in the log files, no errors in the Console, it works on localhost, it doesn't on production env.

How is this possible? Why is the RELOAD_IMAGES_PANEL_JS wicket method called in the client-side, but the respond(AjaxRequestTarget target) method is never riched?

Parfait
  • 104,375
  • 17
  • 94
  • 125
  • Check the `Preserve logs` checkbox in your browser dev tools to verify that there is actually an Ajax call. – martin-g Feb 08 '19 at 16:26
  • This is the problem: the Ajax call doesn't appear in the Network tab, even if the reloadImagesPanel() is called. Today I also noticed that if I add locale=en to my url, it works. My app is in Finnish. – Gozar-Manu Ariana Feb 11 '19 at 08:27
  • It sounds like the issue is in your JavaScript code - in `reloadImagesPanel()` function. – martin-g Feb 11 '19 at 09:23

1 Answers1

1

In the end we found the problem: we have an external tool which can be used to insert javascript code in our app and that code had an issue which apparently broke wicket functionality.

We found the problem by debugging jquery and wicket js code in browser's Console and we compared a working case scenario with a broken one.