I'm using OpenLayers.js v2.11 to manage geographical maps. My project is on JDK 6 + GlassFish, and everything works fine.
After migrating to Java 8 and WildFly, an error is reported in the OpenLayers.js code. This call
this.handler = new handler(this, this.callbacks, this.handlerOptions);
generates the following error: 'handler is not a constructor.'
Normally, JavaScript errors shouldn't depend on the JDK. But could this issue occur when transitioning from GlassFish to WildFly?
After replacing the call with
this.handler = new OpenLayers.Handler(this, this.callbacks, this.handlerOptions);,
the error is corrected. However, I want to understand why there was no error in the same project with JDK 6 and GlassFish.
This call appears in the following method:
initialize: function(layer, handler, options) {
OpenLayers.Control.prototype.initialize.apply(this, [options]);
this.callbacks = OpenLayers.Util.extend(
{
done: this.drawFeature,
modify: function(vertex, feature) {
this.layer.events.triggerEvent(
"sketchmodified", {vertex: vertex, feature: feature}
);
},
create: function(vertex, feature) {
this.layer.events.triggerEvent(
"sketchstarted", {vertex: vertex, feature: feature}
);
}
},
this.callbacks
);
this.layer = layer;
this.handlerOptions = this.handlerOptions || {};
this.handlerOptions.layerOptions = OpenLayers.Util.applyDefaults(
this.handlerOptions.layerOptions, {
renderers: layer.renderers, rendererOptions: layer.rendererOptions
}
);
if (!("multi" in this.handlerOptions)) {
this.handlerOptions.multi = this.multi;
}
var sketchStyle = this.layer.styleMap && this.layer.styleMap.styles.temporary;
if(sketchStyle) {
this.handlerOptions.layerOptions = OpenLayers.Util.applyDefaults(
this.handlerOptions.layerOptions,
{styleMap: new OpenLayers.StyleMap({"default": sketchStyle})}
);
}
this.handler = new handler(this, this.callbacks, this.handlerOptions);
},
Thank you
Replace new handler by new OpenLayers.Handler works fine