diff --git a/framework/source/class/qx/application/Routing.js b/framework/source/class/qx/application/Routing.js index 822ba60ddfc..33d5ee52716 100644 --- a/framework/source/class/qx/application/Routing.js +++ b/framework/source/class/qx/application/Routing.js @@ -124,13 +124,27 @@ qx.Bootstrap.define("qx.application.Routing", { } var path = this.getState(); - if (path == "" || path == null){ - path = defaultRoute || qx.application.Routing.DEFAULT_PATH; - } + path = this._getPathOrFallback(path, defaultRoute); this._executeGet(path, null, true); }, + /** + * Checks if path is valid and registered in channel "get" and then just returns it. + * If the path is not valid either the defaultPath (if given) or the + * {@link #DEFAULT_PATH} will be returned. + * + * @param path {String} Path which gets checked. + * @param defaultPath {String?} Optional default path. + */ + _getPathOrFallback : function(path, defaultPath) { + if (path == "" || path == null || !this.__messaging.isListenerRegisteredFor("get", path)) { + path = defaultPath || qx.application.Routing.DEFAULT_PATH; + } + return path; + }, + + /** * Adds a route handler for the "get" operation. The route gets called * when the {@link #executeGet} method found a match. @@ -232,9 +246,7 @@ qx.Bootstrap.define("qx.application.Routing", { __onChangeHash : function(evt) { var path = evt.getData(); - if (path == "" || path == null){ - path = qx.application.Routing.DEFAULT_PATH; - } + path = this._getPathOrFallback(path); if (path != this.__currentGetPath) { this._executeGet(path, null, true); diff --git a/framework/source/class/qx/event/Messaging.js b/framework/source/class/qx/event/Messaging.js index ead916e1651..ba41601d936 100644 --- a/framework/source/class/qx/event/Messaging.js +++ b/framework/source/class/qx/event/Messaging.js @@ -132,6 +132,31 @@ qx.Bootstrap.define("qx.event.Messaging", }, + /** + * Checks if a listener is registered for the given path in the given channel. + * + * @param channel {String} The channel of the message. + * @param path {String} The path to check. + */ + isListenerRegisteredFor : function(channel, path) { + var listeners = this._listener[channel]; + if (!listeners || qx.lang.Object.isEmpty(listeners)) { + qx.Bootstrap.info("No listener found for channel: " + channel); + return false; + } + + for (var id in listeners) + { + var listener = listeners[id]; + if (listener.regExp.test(path)) { + return true; + } + } + + qx.Bootstrap.info("No listener found for path: " + path); + return false; + }, + /** * Sends a message on the given channel and informs all matching route handlers. * @@ -234,4 +259,4 @@ qx.Bootstrap.define("qx.event.Messaging", return match != undefined; } } -}); \ No newline at end of file +});