Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Qx not Defined
Qx not Defined [message #51098] Thu, 11 October 2007 07:49 Go to next message
Eclipse UserFriend
Originally posted by: cedric.gaillot.thalesraytheon-fr.com

Hi,

Firstable, thanks a lot for answering my question about
internationalization. It is clear for me now.

Otherwise, I have a problem I don't really understand. It happens on
Internet Explorer and sometimes on Firefox.

When I launch my project on Eclipse and then refresh the browser, I have
the following Javascript error. Firebug on Firefox tells me this :

"qx is not defined"

The error is raised when the browser is executing the following lines :

// rap runtime application
qx.log.Logger.ROOT_LOGGER.setMinLevel( qx.log.Logger.LEVEL_OFF );
var req = org.eclipse.swt.Request.getInstance();
req.setUrl( "trs" );
req.setUIRootId( "w1" );
var app = new org.eclipse.swt.Application();
qx.core.Init.getInstance().setApplication( app );
// end rap runtime application

After reading, this lines are located in a Javascript block used of
validation and retrievment of startup conditions.

I have been told this mean there could be a problem of namespace, but I
don't know how to fix it.

As it doesn't always happen on Firefox, I have supposed that it is not a
Java problem but perhaps something like a configuration problem in Web
browser or a wrong parameter in the Eclipse launcher.

Thanks for your help

Cédric G.
Re: Qx not Defined [message #51181 is a reply to message #51098] Thu, 11 October 2007 10:55 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rsternberg.innoopract.com

Hi Cédric,

the "qx not defined" error usually means that a javascript parsing error
has occured and none of the qx classes have been initialized. It's a bit
strange that you say this happens only *somtimes*. Do you pass any extra
javascript to the client?

Ralf

Cédric G. schrieb:
> Hi,
>
> Firstable, thanks a lot for answering my question about
> internationalization. It is clear for me now.
>
> Otherwise, I have a problem I don't really understand. It happens on
> Internet Explorer and sometimes on Firefox.
>
> When I launch my project on Eclipse and then refresh the browser, I have
> the following Javascript error. Firebug on Firefox tells me this :
>
> "qx is not defined"
>
> The error is raised when the browser is executing the following lines :
>
> // rap runtime application
> qx.log.Logger.ROOT_LOGGER.setMinLevel( qx.log.Logger.LEVEL_OFF );
> var req = org.eclipse.swt.Request.getInstance();
> req.setUrl( "trs" );
> req.setUIRootId( "w1" );
> var app = new org.eclipse.swt.Application();
> qx.core.Init.getInstance().setApplication( app );
> // end rap runtime application
>
> After reading, this lines are located in a Javascript block used of
> validation and retrievment of startup conditions.
>
> I have been told this mean there could be a problem of namespace, but I
> don't know how to fix it.
> As it doesn't always happen on Firefox, I have supposed that it is not a
> Java problem but perhaps something like a configuration problem in Web
> browser or a wrong parameter in the Eclipse launcher.
>
> Thanks for your help
>
> Cédric G.
>
Re: Qx not Defined [message #51291 is a reply to message #51181] Fri, 12 October 2007 07:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cedric.gaillot.thalesraytheon-fr.com

Hi,

In fact, we are using Openlayers as well. As Openlayers isn't based on
qooxdoo, we have added to the project an extra javascript file to do the
link between Open layers and our RAP Application :

So, the extra javascript file define a new class "OpenLayersMap" which
extends CanvasLayout :

As for some reasons, we don't want to use the navigation controls
integrated in Openlayers, the js class below is used to send to the server
some mouse events ("mousedown" and "mousemove") thanks the "doMouseEvent"
Function and the Request object.

We have inserted this javascript file in the java package "com.map" of the
project. In the same package, we included a OpenLayersLCA.java file
(extending AbstractWidgetLCA) which gets the events with the read()
function.

Do you think there could be a javascript error in the javascript below ?
In fact, with IE, it never works.
With firefox, it's only sometimes. But often, when i relaunch the
application from Eclipse, it works again.

OpenLayersMap.js
------------------------------------------------------------ ----------------
qx.Class.define( "com.map.OpenLayersMap",
{
extend: qx.ui.layout.CanvasLayout,

// constructor
construct: function( id )
{
this.base( arguments );
this.setHtmlAttribute( "id", id );
this._id = id;
this._map = null;
},

statics : {

doMouseEvent : function(event, id, x, y, lat, lon, button, wheelDelta ) {
if( !org_eclipse_rap_rwt_EventUtil_suspend ) {
var req = org.eclipse.swt.Request.getInstance();
req.addEvent( event, id );
req.addParameter( id + ".x", x );
req.addParameter( id + ".y", y );
req.addParameter( id + ".lat", lat );
req.addParameter( id + ".lon", lon );
req.addParameter( id + ".button", button );
req.addParameter( id + ".wheelDelta", wheelDelta );
req.send();
}
}
},

//Place where we defined the method of this class
members :
{
_doActivate : function()
{
var shell = null;
var parent = this.getParent();
while( shell == null && parent != null )
{
if( parent.classname == "org.eclipse.rap.rwt.widgets.Shell" )
{
shell = parent;
}
parent = parent.getParent();
}
if( shell != null )
{
shell.setActiveChild( this );
}
},

properties :
{
_minimumScale :
{
init : 0,
},
_defaultLat :
{
init : 0.0,
},
_defaultLon :
{
init : 0.0,
}
},

//method used to load the map in the widget
loadMap : function(defaultLat, defaultLon, minimumScale)
{
qx.ui.core.Widget.flushGlobalQueues();

//if we have not load the map by now
if( this._map == null )
{
this.addEventListener("mousedown", this.handleMouseDown);
this.addEventListener("mousemove", this.handleMouseMove);
this._minimumScale = minimumScale;
this._defaultLat = defaultLat;
this._defaultLon = defaultLon;

//we create a parameters list with the kind of projection and the
minimum scale used for the map
var opMap = { projection: "EPSG:4326", minScale: minimumScale,
controls: [] };
//we instanciate a new openlayers map from the API with our parameters
this._map = new OpenLayers.Map(document.getElementById( this._id ),
opMap );
this._map.fallThrough = true;
}
},

getMousePosition: function (evt) {
var x = evt._valueDomEvent.xy.x;
var y = evt._valueDomEvent.xy.y;
return new OpenLayers.Pixel(x, y);
},

handleMouseDown : function(evt)
{
var event = "com.map.widgetClicked";
var mouseLocation = this.getMousePosition(evt);
var geoPt = this._map.getLonLatFromPixel(mouseLocation);
var widgetManager = org.eclipse.swt.WidgetManager.getInstance();
var req = org.eclipse.swt.Request.getInstance();
var id = widgetManager.findIdByWidget( evt.getTarget() );
var x = evt.getClientX();
var y = evt.getClientY();
var button = evt.getButton();
var wheelDelta = 0;
com.map.OpenLayersMap.doMouseEvent( event, id, x, y, geoPt.lat,
geoPt.lon, button, wheelDelta );
},

handleMouseMove : function(evt)
{
var event = "com.trs.rap.widgets.map.widgetMoved";
var mouseLocation = this.getMousePosition(evt);
var geoPt = this._map.getLonLatFromPixel(mouseLocation);
var widgetManager = org.eclipse.swt.WidgetManager.getInstance();
var id = widgetManager.findIdByWidget( evt.getTarget() );
var x = evt.getClientX();
var y = evt.getClientY();
var button = MouseEvent.C_BUTTON_NONE;
var wheelDelta = 0;

com.map.OpenLayersMap.doMouseEvent( event, id, x, y, geoPt.lat,
geoPt.lon, button, wheelDelta );
},

//method called automatically when a resize is called by the
application
_doResize : function()
{
qx.ui.core.Widget.flushGlobalQueues();
if( this._map != null )
{
//we call an update of the size on the map
this._map.updateSize();
}
},

//method called by the server to make a setCenter on the map
//lat : latitude of the point where we want to center the map
//lon : longitude of the point where we want to center the map
setCenter : function(lat, lon)
{
if( this._map != null )
{
//we call a setSenter on the map
this._map.setCenter(new OpenLayers.LonLat(lon, lat),
this._minimumScale);
}
},

//method called by the server to make a zoom in on the map
zoomInJS : function()
{
if( this._map != null )
{
//we call a zoom in on the map
this._map.zoomIn();
}
},

//method called by the server to make a zoom out on the map
zoomOutJS : function()
{
if( this._map != null )
{
//we call a zoom out on the map
this._map.zoomOut();
}
},

addBackgroundLayer : function(name, url, layerNames)
{
var layer = new OpenLayers.Layer.WMS( name,
url,
{layers: layerNames}, {'buffer':4, tileSize: new
OpenLayers.Size(256,256)});
layer.id = name;
layer.setIsBaseLayer(true);
this._map.addLayer(layer);

if(this._map.getNumLayers() == 1)
{
//we finish the loading by calling a setCenter on the map
this._map.setCenter(new OpenLayers.LonLat(this._defaultLon,
this._defaultLat), this._minimumScale);
}

},

addMiddleLayer : function(name, url, layerNames, transparent, visible,
format, minScale)
{
var options = {'minScale': minScale, tileSize: new
OpenLayers.Size(256,256)};
var layer = new OpenLayers.Layer.WMS( name,
url,
{layers: layerNames, 'transparent':transparent, 'format':format},
options);
layer.id = name;
layer.setIsBaseLayer(false);
layer.setVisibility(visible);
this._map.addLayer(layer);
},


addForegroundLayer : function(name)
{
if(this._map != null)
{
var layer = new OpenLayers.Layer.Vector(name);
layer.id = name;
this._map.addLayer(layer);

}
},

deserializeArray: function(values)
{
if(values == null) {
return null;
}

var index = values.indexOf("|");

if(index == -1) {
return null;
}

var nb = values.substr(0, index);

var result = [];

var i = index+1;

var val = 0;

while(i<values.length) {
index = values.indexOf("|", i);
if(index == -1) {
index = values.length;
}
result.push(values.substring(i, index));

i = index+1;
}
return result;
},


addPoint: function(name, id, values, imageIcon)
{
if(this._map != null)
{
var pointArray = this.deserializeArray(values);

if(pointArray != null) {

var layer = this._map.getLayer(name);

var previous = layer.getFeatureById(id);

if(previous != null) {
layer.removeFeatures([previous]);
}

var style = OpenLayers.Util.extend({},
OpenLayers.Feature.Vector.style['default']);
if(imageIcon != null) {
style.externalGraphic = imageIcon;
}
style.fillOpacity = 1.0;

var point = new OpenLayers.Geometry.Point(pointArray[1],
pointArray[0]);
var pointFeature = new OpenLayers.Feature.Vector(point,null,
style);
pointFeature.id = id;

layer.addFeatures([pointFeature]);

}
}
},

removeFeatures: function(name, values)
{
if(this._map != null)
{
var idArray = this.deserializeArray(values);

if(idArray != null) {

var layer = this._map.getLayer(name);

for(var i=0; i < idArray.length; i++) {

var previous = layer.getFeatureById(idArray[i]);

if(previous != null) {
layer.removeFeatures([previous]);
}
}

}
}
},

setBaseLayer : function(name)
{
if(this._map != null)
{
var layer = this._map.getLayer(name);
if(layer != null)
{
this._map.setBaseLayer(layer);
}
}
},

setLayerVisible : function(name, visible)
{
if(this._map != null)
{
var layer = this._map.getLayer(name);
if(layer != null)
{
layer.setVisibility(visible);
}
}
},

//method called by the server to change the index of a layer in the map
raiseLayer : function( name, delta)
{
if(this._map != null)
{
var layer = this._map.getLayer(name);
if(layer != null)
{
this._map.raiseLayer(layer, delta);
}
}
},

getLayerByName : function(name)
{
for(var i=0; i < this._map.layers; i++)
{
if (this._map.layers[i] == name)
{
return this._map.layers[i];
}
}
return null;
}
}
} );
------------------------------------------------------------ ------------------

OpenLayersLCA.java
------------------------------------------------------------ ------------------
import java.io.IOException;

import org.eclipse.rwt.lifecycle.AbstractWidgetLCA;
import org.eclipse.rwt.lifecycle.ControlLCAUtil;
import org.eclipse.rwt.lifecycle.IWidgetAdapter;
import org.eclipse.rwt.lifecycle.JSWriter;
import org.eclipse.rwt.lifecycle.WidgetLCAUtil;
import org.eclipse.rwt.lifecycle.WidgetUtil;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Item;
import org.eclipse.swt.widgets.Widget;

import com.trs.rap.widgets.map.GxBase;
import com.trs.rap.widgets.map.MouseEvent;
import com.trs.rap.widgets.map.MouseEventJSConst;
import com.trs.rap.widgets.map.MouseEventJSConst.TypeButton;

/**
* The LCA is the right place to mediate between client and server. The
way from
* server to client is handled in the renderXXX methods.
*/
public class OpenLayersLCA extends AbstractWidgetLCA {

/*
* (non-Javadoc)
*
* @see
org.eclipse.rwt.lifecycle.AbstractWidgetLCA#preserveValues(o rg.eclipse.swt.widgets.Widget)
*/
public void preserveValues(final Widget widget) {

ControlLCAUtil.preserveValues((Control) widget);
IWidgetAdapter adapter = WidgetUtil.getAdapter(widget);
}

/**
* Method used to see the changes made on the client side
*/
public void readData(final Widget widget) {
IWidgetAdapter adapter = WidgetUtil.getAdapter(widget);
Item item = null;
MouseEvent event = null;

if (WidgetLCAUtil.wasEventSent(widget,
MouseEventJSConst.EVENT_WIDGET_CLICKED)) {
event = createMouseEvent(widget, item, MouseEvent.WIDGET_CLICKED);
} else if (WidgetLCAUtil.wasEventSent(widget,
MouseEventJSConst.EVENT_WIDGET_MOVED)) {
event = createMouseEvent(widget, item, MouseEvent.WIDGET_MOVED);
}
if (event != null) {
event.processEvent();
}
}

private static MouseEvent createMouseEvent(final Widget widget,
final Item item, final int type) {

double x;
double y;
double lat;
double lon;
String JSbutton = null;
int button;
double wheelDelta;

if (widget instanceof Control) {
x = Double.parseDouble(WidgetLCAUtil.readPropertyValue(widget,
MouseEventJSConst.MOUSE_EVENT_X_PROPERTY));
y = Double.parseDouble(WidgetLCAUtil.readPropertyValue(widget,
MouseEventJSConst.MOUSE_EVENT_Y_PROPERTY));
lat = Double.parseDouble(WidgetLCAUtil.readPropertyValue(widget,
MouseEventJSConst.MOUSE_EVENT_LAT_PROPERTY));
lon = Double.parseDouble(WidgetLCAUtil.readPropertyValue(widget,
MouseEventJSConst.MOUSE_EVENT_LON_PROPERTY));

JSbutton = WidgetLCAUtil.readPropertyValue(widget,
MouseEventJSConst.MOUSE_EVENT_BUTTON_PROPERTY);
if (TypeButton.MIDDLE.equals(JSbutton)) {
button = MouseEvent.MIDDLEBUTTON;
} else if (TypeButton.LEFT.equals(JSbutton)) {
button = MouseEvent.LEFTBUTTON;
} else if (TypeButton.RIGHT.equals(JSbutton)) {
button = MouseEvent.RIGHTBUTTON;
} else {
button = MouseEvent.NONE;
}
wheelDelta = Double.parseDouble(WidgetLCAUtil.readPropertyValue(
widget, MouseEventJSConst.MOUSE_EVENT_WHEELDELTA_PROPERTY));
} else {
x = 0;
y = 0;
lat = 0;
lon = 0;
button = MouseEvent.NONE;
wheelDelta = 0;
}

return new MouseEvent(widget, type, x, y, lat, lon, button, wheelDelta);
}

/**
* Method called once at the initialization of the client widget
*/
public void renderInitialization(final Widget widget) throws IOException {
// we create a writer to connect to the widget
JSWriter writer = JSWriter.getWriterFor(widget);
// we get the id from the widget
String id = WidgetUtil.getId(widget);
// we put our openLayers widget in the created widget
writer.newWidget("com.trs.rap.widgets.map.openlayers.OpenLayersMap ",
new Object[] { id });
}

/**
* Method called at every changed made in the client
*/
public void renderChanges(final Widget widget) throws IOException {
// we get our widget
OpenLayers openLayer = (OpenLayers) widget;
// write in the client widget the changed
ControlLCAUtil.writeChanges(openLayer);
boolean hasListener = SelectionEvent.hasListener(openLayer);
// we load the map in the widget
openLayer.loadMap(GxBase.getInstance().getMinimumScale());
}

/**
* Method called just before the call of the Dispose() method which end
the
* widget
*/
public void renderDispose(final Widget widget) throws IOException {
// nothing to do
}

/*
* (non-Javadoc)
*
* @see
org.eclipse.rwt.lifecycle.AbstractWidgetLCA#createResetHandl erCalls(java.lang.String)
*/
public void createResetHandlerCalls(String typePoolId) throws IOException
{
// nothing to do
}

/*
* (non-Javadoc)
*
* @see
org.eclipse.rwt.lifecycle.AbstractWidgetLCA#getTypePoolId(or g.eclipse.swt.widgets.Widget)
*/
public String getTypePoolId(Widget widget) throws IOException {
return null;
}
}
------------------------------------------------------------ -------------

Thanks,

Cédric G.
Re: Qx not Defined [message #51429 is a reply to message #51098] Fri, 12 October 2007 16:49 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cedric.gaillot.thalesraytheon-fr.com

Hi,

Finally, I found what the problem is.

As I wasn't particulary clear, in my previous post, I explain again what
my problem was :

We created a customed widget (As it is explained in the following tutorial
:
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.rap/org .eclipse.rap.help/help/html/advanced/custom-widget.html?revi sion=HEAD&root=Technology_Project)

Our customed widget (Controlled on client side by our own qooxdoo class
named OpenLayersMap.js) was using external JS libraries (OpenLayers JS
libraries).

The problem was that IE was returning me a "qx is not defined" error.
After some experiments, I found the problem was located in the JS File
OpenLayersMap.js (See the code in the post below)

After removing all the code from the file and reinsert it step by step, I
found
the "init" statement in the "properties" statement causes the problem.

When I remove it, it appears to work fine. Now, I have still to find why.
Is there something to do previously to use this statement ?

Thanks

Cédric G.
Re: Qx not Defined [message #51456 is a reply to message #51429] Fri, 12 October 2007 17:11 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rsternberg.innoopract.com

Hi Cédric,

fine that you found the problem, I was a bit clueless. But looking at
the js statement you pointed to, I'm pretty sure that your problem is
caused by the trailing comma in the list, just after setting the init
param. This fails in IE but not in FF, indeed. Still, this does not
explain the random problems with FF.

Regards,
Ralf

Cédric G. schrieb:
> Hi,
> Finally, I found what the problem is.
> As I wasn't particulary clear, in my previous post, I explain again what
> my problem was :
>
> We created a customed widget (As it is explained in the following
> tutorial :
> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.rap/org .eclipse.rap.help/help/html/advanced/custom-widget.html?revi sion=HEAD&root=Technology_Project)
>
>
> Our customed widget (Controlled on client side by our own qooxdoo class
> named OpenLayersMap.js) was using external JS libraries (OpenLayers JS
> libraries).
>
> The problem was that IE was returning me a "qx is not defined" error.
> After some experiments, I found the problem was located in the JS File
> OpenLayersMap.js (See the code in the post below)
>
> After removing all the code from the file and reinsert it step by step,
> I found
> the "init" statement in the "properties" statement causes the problem.
>
> When I remove it, it appears to work fine. Now, I have still to find
> why. Is there something to do previously to use this statement ?
>
> Thanks
>
> Cédric G.
>
>
Re: Qx not Defined [message #51761 is a reply to message #51456] Tue, 16 October 2007 09:21 Go to previous message
Eclipse UserFriend
Originally posted by: cedric.gaillot.thalesraytheon-fr.com

Hi,

Thanks, that's was eventually the problem.

Now, It works fine with IE and FireFox. I have no more the random problem
with FireFox. I think it was the same with IE. Perhaps, FireFox Javascript
Interpretor is more flexible than IE ?
Previous Topic:404 error
Next Topic:same view multiple times in perspective
Goto Forum:
  


Current Time: Fri Apr 26 18:45:45 GMT 2024

Powered by FUDForum. Page generated in 0.03649 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top