Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 318096 - [upload] widget throws javascript error if reset() is called too early
Summary: [upload] widget throws javascript error if reset() is called too early
Status: RESOLVED FIXED
Alias: None
Product: RAP
Classification: RT
Component: RWT (show other bugs)
Version: 1.3   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-26 16:34 EDT by Michal Tkacz CLA
Modified: 2011-04-04 04:21 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michal Tkacz CLA 2010-06-26 16:34:19 EDT
Environment: Chrome 5.0.375.70 and Firefox 3.6.3 on Ubuntu Linux 10.04

In certain circumstances upload widget fails with the following javascript error:

Could not evaluate javascript response:
Error: Error in property lastFileUploaded of class org.eclipse.rwt.widgets.Upload in method setLastFileUploaded with incoming value 'null': Null value is not allowed!

It seems to happen when the reset() method is called after the widget is created but before the javascript code creating it is returned to the client (i.e. within the same life cycle). I managed to reproduce it by slightly modifying EntryPoint class inside the org.eclipse.rwt.widgets.upload.demo bundle:

...
this.upload = new Upload(this.uploadContainer, getStyle(), getUploadFlags());
this.upload.reset(); // <-- ADDED LINE
this.upload.setBrowseButtonText(this.browseBtnText);
...

I believe the solution is to change the reset() method so that it sets lastFileUploaded to "" and not to null.

This solved the problem for me but at the same time led to another javascript error which I wasn't able to debug.
The error is different under Chrome and Firefox.

Under Chrome:

Could not evaluate javascript response:
TypeError: Cannot set property 'value' of undefined

Under Firefox:

Could not evaluate javascript response:
TypeError: this._input is undefined
Comment 1 Ivan Furnadjiev CLA 2010-07-06 06:05:38 EDT
Fixed in CVS HEAD.
Comment 2 Michal Tkacz CLA 2010-07-07 05:17:27 EDT
Thanks!
Comment 3 Michal Tkacz CLA 2011-04-02 05:10:22 EDT
Can we have it backported to v13_Maintenance?
Comment 4 Ivan Furnadjiev CLA 2011-04-04 03:16:33 EDT
Upload widget from sandbox in not part of the build. Thus, I have no idea which state of the upload widget corresponds (work with) to 1.3. But the fix is to replace the line 279 in Upload.js:
---
if (this._uploadField) {
---
with:
---
if (this._uploadField.isCreated()) {
You could port it yourself in your Upload widget.
Comment 5 Michal Tkacz CLA 2011-04-04 04:21:29 EDT
Ok, thanks.