Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 321282 - Loading Javascript resources from bundles with dependencies
Summary: Loading Javascript resources from bundles with dependencies
Status: RESOLVED FIXED
Alias: None
Product: RAP
Classification: RT
Component: RWT (show other bugs)
Version: 1.3   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 1.4 M7   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-29 21:21 EDT by Paul Kendall CLA
Modified: 2011-04-30 08:34 EDT (History)
1 user (show)

See Also:


Attachments
Patch to add resource dependency checking (4.72 KB, patch)
2010-07-29 21:21 EDT, Paul Kendall CLA
no flags Details | Diff
Updated and refactored patch (14.60 KB, patch)
2011-04-29 05:12 EDT, Ivan Furnadjiev CLA
no flags Details | Diff
New version of the patch (18.67 KB, patch)
2011-04-30 08:28 EDT, Ivan Furnadjiev CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Kendall CLA 2010-07-29 21:21:23 EDT
Created attachment 175534 [details]
Patch to add resource dependency checking

I have a custom widget that uses the excanvas resource in the incubator repository. Sometimes my bundle gets loaded first and throws a javascript error because the canvas is not loaded.

I have created a patch which allows a resource to specify other resources as dependencies and the registerResources then creates the list order of resources based on when the dependencies are satisfied.
Comment 1 Paul Kendall CLA 2010-07-29 21:53:10 EDT
Slight error in the definition of the dependency in the schema.
It should be minimum 0 occurrences.
Comment 2 Austin Riddle CLA 2010-07-30 09:39:40 EDT
(In reply to comment #0)

Pretty slick. I like it.
Comment 3 Austin Riddle CLA 2010-07-30 10:04:06 EDT
(In reply to comment #1)

In my assessment, the schema for the class attribute of the dependency element should be a java type, not a string type.
Comment 4 Paul Kendall CLA 2010-07-30 17:22:35 EDT
(In reply to comment #3)
> (In reply to comment #1)
> 
> In my assessment, the schema for the class attribute of the dependency element
> should be a java type, not a string type.

It is isn't it?
+               <appInfo>
+                  <meta.attribute kind="java" basedOn=":org.eclipse.rwt.resources.IResource"/>
+               </appInfo>

If that's wrong, then yes, it should be a java type.
Comment 5 Austin Riddle CLA 2010-07-30 17:26:00 EDT
(In reply to comment #4)
Sorry, I misread that part of the patch.
Comment 6 Ivan Furnadjiev CLA 2011-04-29 05:12:03 EDT
Created attachment 194340 [details]
Updated and refactored patch

Thanks for the patch Paul. In the attached patch I did some changes, refactorings and improvements.
resource.exsd:
1. Renamed the new element to "dependsOn"
2. Changed the minOccurs to 0.
3. Make the class attribute of the "dependsOn" element required.
4. Added a documentation.
EngineConfigWrapper.java
1. Renamed some variables
2. Replaces iterator loop with array loop. For me, under some circumstances, removing the element from the iterator while iterating leaded to strange results.
3. Added additional while loop to recheck the differed resources if new resource has been registered. Without it, it's possible to leave unregistered differed resources if we have a dependencies between differed resources - see EngineConfigWrapperTest.

Added a RAP UI EngineConfigWrapperTest to test the functionality (with all need changes for it).
Comment 7 Paul Kendall CLA 2011-04-29 16:37:36 EDT
Awesome, thanks Ivan, these changes certainly make it better.
Do you think that it will make it in for 1.4?
Comment 8 Ivan Furnadjiev CLA 2011-04-30 08:28:52 EDT
Created attachment 194422 [details]
New version of the patch

After discussion with Ralf, we decided to add additional optional "id" attribute to the resource element. The "dependsOn" element now have a required "resourceId" attribute to make a reference to the resource on which it depends.
Comment 9 Ivan Furnadjiev CLA 2011-04-30 08:34:05 EDT
Applied patch to CVS HEAD. Yes, Paul... it will be included in the upcoming 1.4M7 milestone.