diff --git a/pom.xml b/pom.xml
index 3bf08173d..6e001555d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -71,6 +71,16 @@
4.11
test
+
+ com.google.elemental2
+ elemental2-core
+ 1.0.0-beta-1
+
+
+ com.google.elemental2
+ elemental2-dom
+ 1.0.0-beta-1
+
diff --git a/src/main/java/gwt/material/design/addins/client/fileuploader/MaterialFileUploader.java b/src/main/java/gwt/material/design/addins/client/fileuploader/MaterialFileUploader.java
index 5d990dd55..483a04141 100644
--- a/src/main/java/gwt/material/design/addins/client/fileuploader/MaterialFileUploader.java
+++ b/src/main/java/gwt/material/design/addins/client/fileuploader/MaterialFileUploader.java
@@ -235,13 +235,13 @@ protected void initDropzone(Element e, Element template, String previews, Elemen
uploader.on("error", (file, response) -> {
String code = "200";
if (file.xhr != null) {
- code = file.xhr.status;
+ code = String.valueOf(file.xhr.status);
}
if (response.indexOf("401") >= 0) {
response = "Unauthorized. Your session may have expired. Log in and try again.";
globalResponse = response;
- UnauthorizedEvent.fire(this, convertUploadFile(file), new UploadResponse(file.xhr.status, file.xhr.statusText, response));
+ UnauthorizedEvent.fire(this, convertUploadFile(file), new UploadResponse(file.xhr, response));
}
if (response.indexOf("404") >= 0) {
@@ -255,7 +255,7 @@ protected void initDropzone(Element e, Element template, String previews, Elemen
}
$(file.previewElement).find("#error-message").html(response);
- ErrorEvent.fire(this, convertUploadFile(file), new UploadResponse(file.xhr.status, file.xhr.statusText, response));
+ ErrorEvent.fire(this, convertUploadFile(file), new UploadResponse(file.xhr, response));
});
uploader.on("totaluploadprogress", (progress, file, response) -> {
@@ -273,16 +273,16 @@ protected void initDropzone(Element e, Element template, String previews, Elemen
});
uploader.on("sending", file -> {
- SendingEvent.fire(this, convertUploadFile(file), new UploadResponse(file.xhr.status, file.xhr.statusText));
+ SendingEvent.fire(this, convertUploadFile(file), new UploadResponse(file.xhr));
});
uploader.on("success", (file, response) -> {
globalResponse = response;
- SuccessEvent.fire(this, convertUploadFile(file), new UploadResponse(file.xhr.status, file.xhr.statusText, response));
+ SuccessEvent.fire(this, convertUploadFile(file), new UploadResponse(file.xhr, response));
});
uploader.on("complete", file -> {
- CompleteEvent.fire(this, convertUploadFile(file), new UploadResponse(file.xhr.status, file.xhr.statusText, globalResponse));
+ CompleteEvent.fire(this, convertUploadFile(file), new UploadResponse(file.xhr, globalResponse));
});
uploader.on("canceled", file -> {
diff --git a/src/main/java/gwt/material/design/addins/client/fileuploader/base/UploadResponse.java b/src/main/java/gwt/material/design/addins/client/fileuploader/base/UploadResponse.java
index db17199de..0b0ddadc3 100644
--- a/src/main/java/gwt/material/design/addins/client/fileuploader/base/UploadResponse.java
+++ b/src/main/java/gwt/material/design/addins/client/fileuploader/base/UploadResponse.java
@@ -19,6 +19,8 @@
*/
package gwt.material.design.addins.client.fileuploader.base;
+import elemental2.dom.XMLHttpRequest;
+
/**
* Upload Response with Code (e.g 404, 503, 200) and message ("File Upload url not found etc."
*
@@ -29,16 +31,19 @@ public class UploadResponse {
private String code;
private String message;
private String body;
+ private final XMLHttpRequest xhr;
- public UploadResponse(String code, String message) {
- this.code = code;
- this.message = message;
+ public UploadResponse(XMLHttpRequest xhr) {
+ this.code = String.valueOf(xhr.status);
+ this.message = xhr.statusText;
+ this.xhr=xhr;
}
- public UploadResponse(String code, String message, String body) {
- this.code = code;
- this.message = message;
+ public UploadResponse(XMLHttpRequest xhr, String body) {
+ this.code = String.valueOf(xhr.status);
+ this.message = xhr.statusText;
this.body = body;
+ this.xhr=xhr;
}
public String getCode() {
@@ -64,4 +69,8 @@ public String getBody() {
public void setBody(String body) {
this.body = body;
}
+
+ public XMLHttpRequest getXhr() {
+ return xhr;
+ }
}
diff --git a/src/main/java/gwt/material/design/addins/client/fileuploader/js/File.java b/src/main/java/gwt/material/design/addins/client/fileuploader/js/File.java
index 8f014572a..5ecd62965 100644
--- a/src/main/java/gwt/material/design/addins/client/fileuploader/js/File.java
+++ b/src/main/java/gwt/material/design/addins/client/fileuploader/js/File.java
@@ -20,6 +20,7 @@
package gwt.material.design.addins.client.fileuploader.js;
import com.google.gwt.dom.client.Element;
+import elemental2.dom.XMLHttpRequest;
import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsProperty;
import jsinterop.annotations.JsType;
@@ -40,7 +41,7 @@ public class File {
public String type;
@JsProperty
- public XHR xhr;
+ public XMLHttpRequest xhr;
@JsProperty
public Element previewElement;
diff --git a/src/main/resources/gwt/material/design/addins/GwtMaterialAddinsBase.gwt.xml b/src/main/resources/gwt/material/design/addins/GwtMaterialAddinsBase.gwt.xml
index 458377c87..30d1bb4a8 100644
--- a/src/main/resources/gwt/material/design/addins/GwtMaterialAddinsBase.gwt.xml
+++ b/src/main/resources/gwt/material/design/addins/GwtMaterialAddinsBase.gwt.xml
@@ -27,6 +27,8 @@
+
+