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:
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?