Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Buschtöns2014-02-05 11:03:03 -0500
committerTim Buschtöns2014-02-05 11:03:03 -0500
commitbb29ecd6b70d39545e835704d798c2a853c076ea (patch)
tree8a30534a0e965f1b2aca2000841b3184d80280d5
parentf58c3cbcb83cdbc3e988ff7ff665abf40cfd4053 (diff)
downloadorg.eclipse.rap.incubator.dropdown-streams/2.2.tar.gz
org.eclipse.rap.incubator.dropdown-streams/2.2.tar.xz
org.eclipse.rap.incubator.dropdown-streams/2.2.zip
Enable AutoSuggest to handle events fired before the model is createdstreams/2.2
Text and DropDown can fire events before the model object exists, (caused by protocol operations), in which case the client would crash. They are now delayed until the objects are created, which must be in the same request - otherwise the client still crashes, which is correct.
-rw-r--r--bundles/org.eclipse.rap.addons.autosuggest/src/org/eclipse/rap/addons/autosuggest/internal/resources/EventDelegator.js26
1 files changed, 20 insertions, 6 deletions
diff --git a/bundles/org.eclipse.rap.addons.autosuggest/src/org/eclipse/rap/addons/autosuggest/internal/resources/EventDelegator.js b/bundles/org.eclipse.rap.addons.autosuggest/src/org/eclipse/rap/addons/autosuggest/internal/resources/EventDelegator.js
index 70e00da..4fc4420 100644
--- a/bundles/org.eclipse.rap.addons.autosuggest/src/org/eclipse/rap/addons/autosuggest/internal/resources/EventDelegator.js
+++ b/bundles/org.eclipse.rap.addons.autosuggest/src/org/eclipse/rap/addons/autosuggest/internal/resources/EventDelegator.js
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013 EclipseSource.
+ * Copyright (c) 2013, 2014 EclipseSource.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -9,7 +9,7 @@
* EclipseSource - initial API and implementation
******************************************************************************/
-//@ sourceURL=DataBinding.js
+//@ sourceURL=EventDelegator.js
///////////////////
// Event Delegation
@@ -17,8 +17,22 @@
var MODEL_KEY = "org.eclipse.rap.addons.autosuggest#Model";
function handleEvent( event ) {
- var model = rap.getObject( event.widget.getData( MODEL_KEY ) );
- var autoSuggestListener
- = rwt.remote.ObjectRegistry.getObject( model.get( "autoSuggestListenerId" ) );
- autoSuggestListener( event );
+ withObject( event.widget.getData( MODEL_KEY ), function( model ) {
+ var autoSuggestListener
+ = rwt.remote.ObjectRegistry.getObject( model.get( "autoSuggestListenerId" ) );
+ autoSuggestListener( event );
+ } );
+}
+
+function withObject( id, callback ) {
+ // compensating for the server creating the objects in the wrong order:
+ if( rap.getObject( id ) ) {
+ callback( rap.getObject( id ) );
+ } else {
+ var wrapper = function() {
+ callback( rap.getObject( id ) );
+ rap.off( "render", wrapper );
+ };
+ rap.on( "render", wrapper );
+ }
}

Back to the top