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

Bug 467509

Summary: Date time in dialog processes javascript error when clicking 3 times really fast
Product: [RT] RAP Reporter: Wim Anckaert <wian>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P1 CC: ivan
Version: 2.3   
Target Milestone: 3.0 RC2   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Wim Anckaert CLA 2015-05-18 09:06:20 EDT
Hi,

I have a problem when using DateTime on a jface dialog.
(target in development is : RAP 2.3/SR2-20150128-1013, building via tycho, error occurs in chrome  42.0.2311.135 m, seen it too in chrome version 34.xxx)

When the user selects a date but clicks 3 times really fast then it throws the following javascript error in development mode: (in production the application runs in a loop => hanging the client)

Error: Error: Invalid target for ServerObject, or target not in ObjectManager

  Stack: Error: Invalid target for ServerObject, or target not in ObjectManager
    at Object.rwt.remote.RemoteObjectFactory.getRemoteObject (DropDown.js:68340:13)
    at rwt.qx.Class.define.members.getRemoteObject (DropDown.js:67062:45)
    at Object.rwt.remote.EventUtil.notifySelected (DropDown.js:42804:18)
    at rwt.qx.Class.define.members._onSend (DropDown.js:64133:28)
    at rwt.qx.Class.define.members.dispatchSimpleEvent (DropDown.js:4194:27)
    at rwt.qx.Class.define.members.sendImmediate (DropDown.js:67035:14)
    at null. (DropDown.js:66953:12)
    at rwt.qx.Class.define.members._dispatchEvent (DropDown.js:4230:18)
    at rwt.qx.Class.define.members.dispatchEvent (DropDown.js:4171:12)
    at rwt.qx.Class.define.members._oninterval (DropDown.js:4863:16)
  Debug: on


class NewDatePickerPanel extends Dialog implements SelectionListener {

    private static final long serialVersionUID = 1L;

    private Calendar date;

    private DateTime dateTime;

    protected NewDatePickerPanel(Shell parentShell, Calendar date) {
        super(parentShell);
        this.date = date;
    }

    @Override
    protected Point getInitialSize() {
        return new org.eclipse.swt.graphics.Point(277, 240);
    }

    @Override
    protected Control createDialogArea(Composite parent) {
        Composite comp = new NoMarginComposite(parent, 2);

        dateTime = new DateTime(comp, SWT.CALENDAR);
        dateTime.addSelectionListener(this);
        return comp;
    }

    @Override
    public void widgetSelected(SelectionEvent e) {
        okPressed();
    }

    @Override
    public void widgetDefaultSelected(SelectionEvent e) {
        okPressed();
    }

    @Override
    protected void okPressed() {
        date.set(Calendar.YEAR, dateTime.getYear());
        date.set(Calendar.MONTH, dateTime.getMonth());
        date.set(Calendar.DAY_OF_MONTH, dateTime.getDay());
        super.okPressed();
    }

    Calendar getDate() {
        return date;
    }

}
Comment 1 Ivan Furnadjiev CLA 2015-05-26 03:17:13 EDT
Fixed with change https://git.eclipse.org/r/#/c/48346/
Comment 2 Wim Anckaert CLA 2015-05-26 05:02:21 EDT
Hi Ivan,
tx for the fix!
Is this now fixed for 2.3 too?

I can't conclude that from your fixed link.
Comment 3 Ivan Furnadjiev CLA 2015-05-26 05:11:45 EDT
(In reply to Wim Anckaert from comment #2)
> Hi Ivan,
> tx for the fix!
> Is this now fixed for 2.3 too?
> 
> I can't conclude that from your fixed link.

It's only fixed in master (3.0RC2). There are no more service releases planned for 2.3.
Comment 4 Wim Anckaert CLA 2015-05-26 05:17:52 EDT
Is there a way we can fix it, a workaround ?
For example :
- Disposing the widget ourselfes before closing dialog?
- Removing listeners of the widget before/after disposing?

We are not going to be able to go to RAP 3.0 really soon as our target platform (iSeries v6) has only support untill java 6.
Comment 5 Ivan Furnadjiev CLA 2015-05-26 05:28:13 EDT
(In reply to Wim Anckaert from comment #4)
> Is there a way we can fix it, a workaround ?
> For example :
> - Disposing the widget ourselfes before closing dialog?
> - Removing listeners of the widget before/after disposing?
> 
> We are not going to be able to go to RAP 3.0 really soon as our target
> platform (iSeries v6) has only support untill java 6.

I see two options:
1. Patch RWT bundle from 2.3 with the Gerrit change. I'm pretty sure it's compatible.
2. Execute a JavaScript at runtime (in your entry point) that patches HandlerUtil.js#notifySelected and HandlerUtil.js#notifyDefaultSelected - add a dispose check.
Comment 6 Wim Anckaert CLA 2015-05-26 08:04:15 EDT
Hi Ivan,
Is there an example somewhere how to patch this in the entry point.
I didn't find anything simular in the forums.
tx !
Comment 7 Wim Anckaert CLA 2015-05-26 10:48:06 EDT
a solution can be found on the forum : https://www.eclipse.org/forums/index.php/t/1066882/