Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 449432

Summary: Nebula grid: UnsupportedOperationException after click on RWT hyperlink
Product: [RT] RAP Reporter: Thomas Hendel <hendel>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.0   
Target Milestone: 3.0 M3   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Thomas Hendel CLA 2014-10-31 04:40:03 EDT
Activating RWT hyperlinks (myGrid.setData(RWT.MARKUP_ENABLED, Boolean.TRUE)) leads to an UnsupportedOperationException if the user clicks on such a hyperlink.
The exception is thrown in GridOperationHandler.readIndex()
(package org.eclipse.nebula.widgets.grid.internal.gridkit).
The retrieved JSON value is not null. It is not a number, but a literal conatining "null" due to the parameters of the event fired in Grid.js, line 556:
    this._fireSelectionChanged( item, "hyperlink", null, text );


Changing the return statement in GridOperationHandler.readIndex() from
    return value == null ? 0 : value.asInt();
to
    return value == null || !value.isNumber() ? 0 : value.asInt();
would fix that. But I'm not surce whether it is ok this way...
Comment 1 Ivan Furnadjiev CLA 2014-10-31 05:03:59 EDT
I don't understand how this is possible - index parameter to be "null" literal. If you look at Grid.ja#_fireSelectionChanged function there is a check if inxed is number or not. If it's not a number the index parameter is "undefined" (missing) and on the server-side it is null. Which RAP version are you using? Is it reproducible with RAP 3.0M2?
Comment 2 Thomas Hendel CLA 2014-10-31 05:16:16 EDT
It is reproducible in RAP 3.0M2; and I use the nebula grid that comes with RAP 3.0M2.
Comment 3 Ivan Furnadjiev CLA 2014-10-31 05:20:42 EDT
OK... I can reproduce it with our Controls Demo -> Nebula Grid tab.
Comment 4 Thomas Hendel CLA 2014-10-31 05:26:57 EDT
In the debugger one can see this:

call stack:
GridOperationHandler.readIndex(JsonObject) line: 252	
GridOperationHandler.handleNotifySelection(Grid, JsonObject) line: 182	
GridOperationHandler.handleNotify(Grid, String, JsonObject) line: 69	
GridOperationHandler.handleNotify(Control, String, JsonObject) line: 1	
GridOperationHandler(ControlOperationHandler<T>).handleNotify(Widget, String, JsonObject) line: 1	
GridOperationHandler(WidgetOperationHandler<T>).handleNotify(String, JsonObject) line: 51	
ProtocolUtil.handleOperation(OperationHandler, Operation) line: 70	
GridLCA(AbstractWidgetLCA).readData(Widget) line: 51	
GridLCA.readData(Widget) line: 109	

the JsonObject in GridOperationHandler.readIndex(JsonObject) looks like this:
{"item":"w141","detail":"hyperlink","index":null,"text":"303","button":1,"shiftKey":false,"ctrlKey":false,"altKey":false}

The "clientMessage" in GridLCA(AbstractWidgetLCA).readData(Widget) looks like this:
{"head":{"requestCounter":7},"operations":[["notify","w117","MouseUp",{"x":615,"y":295,"time":10849,"button":1,"shiftKey":false,"ctrlKey":false,"altKey":false}],["notify","w117","Selection",{"item":"w141","detail":"hyperlink","index":null,"text":"303","button":1,"shiftKey":false,"ctrlKey":false,"altKey":false}],["set","w1",{"cursorLocation":[615,295]}]]}

May be a bug in the creation of the JSON object?
Comment 5 Ivan Furnadjiev CLA 2014-10-31 05:30:57 EDT
It seems that in JavaScript isNaN( null ) returns false - null is considered as number. Fix is pending.
Comment 6 Ivan Furnadjiev CLA 2014-10-31 06:16:45 EDT
Pending change: https://git.eclipse.org/r/#/c/35719/
Comment 7 Ivan Furnadjiev CLA 2014-11-03 08:01:52 EST
Fixed in master with change https://git.eclipse.org/r/#/c/35719/