Closed fizzi closed 6 years ago
It's not a problem on gwt-polymer-elements, but in the way iron-ajax
checks whether a value is a javascript Object
.
Since GWT creates new objects in the sandboxed $wnd
iframe via the JavaScriptObject.createObject()
method, those objects are not instanceof Object
in the application window.
As a workaround, create your headers using any of these ways:
@JsMethod(namespace = JsPackage.GLOBAL, name = "Object")
static native JavaScriptObject createObject();
static native JavaScriptObject createObject() /*-{
return $wnd.Object();
}-*/;
And set the headers in this way:
JavaScriptObject openAmUser = createObject();
Polymer.property(openAmUser, "X-OpenAM-Username", "xxxxxx");
Polymer.property(openAmUser, "X-OpenAM-Password", "xxxxxx");
Polymer.property(openAmUser, "x-requested-with", "XMLHttpRequest");
ajax.setHeaders(openAmUser);
Reported issue to polymer : https://github.com/PolymerElements/iron-ajax/issues/246 Reported issue to gwtproject : https://github.com/gwtproject/gwt/issues/9464
fixend
JSONObject openAmUser = new JSONObject(); openAmUser.put("X-OpenAM-Username",new JSONString("xxxxxx")); openAmUser.put("X-OpenAM-Password",new JSONString("xxxxxx")); openAmUser.put("x-requested-with",new JSONString("XMLHttpRequest"));