This is an automated email from the ASF dual-hosted git repository.

harbs pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git


The following commit(s) were added to refs/heads/develop by this push:
     new 164dc57  Enable more defaults
164dc57 is described below

commit 164dc5795be2957d927b332165cbfc0e963854ea
Author: Harbs <[email protected]>
AuthorDate: Wed Feb 12 02:31:22 2020 +0200

    Enable more defaults
---
 .../src/main/royale/org/apache/royale/routing/ParameterRoute.as   | 8 ++++++++
 .../main/royale/org/apache/royale/routing/RouteToParameters.as    | 8 +++++++-
 .../Basic/src/main/royale/org/apache/royale/routing/Router.as     | 4 ++++
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git 
a/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/ParameterRoute.as
 
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/ParameterRoute.as
index 14d1dbb..682c6e8 100644
--- 
a/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/ParameterRoute.as
+++ 
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/ParameterRoute.as
@@ -32,6 +32,14 @@ package org.apache.royale.routing
      * Parameter key to use
      */
     public var key:String;
+    /**
+     * If a default value is specified, the callback will be called
+     * with the default if no matching key is specified in the URL
+     */
+    public var defaultValue:String;
+    /**
+     * Optional window title
+     */
     public var title:String;
     /**
      * Function to call if the parameter exists. (The value is supplied as an 
argument.)
diff --git 
a/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/RouteToParameters.as
 
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/RouteToParameters.as
index bb64ad7..ee725ae 100644
--- 
a/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/RouteToParameters.as
+++ 
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/RouteToParameters.as
@@ -79,11 +79,17 @@ package org.apache.royale.routing
       {
         for(var i:int=0;i<routes.length;i++){
           var route:ParameterRoute = routes[i];
+          var value:String = route.defaultValue;
           if(route.key in params)
           {
-            route.callback(params[route.key]);
+            value = params[route.key];
+          }
+          if(value)
+          {
+            route.callback(value);
             if(route.title)
               host.routeState.title = route.title;
+
           }
         }
       }      
diff --git 
a/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/Router.as 
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/Router.as
index aa113d8..08df81b 100644
--- 
a/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/Router.as
+++ 
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/Router.as
@@ -108,6 +108,10 @@ package org.apache.royale.routing
         {
           hashChangeHandler();
         }
+        else// if there's no hash we should still dispatch a stateChange event 
so the beads can set defaults
+        {
+          dispatchEvent(new Event("stateChange"));
+        }
       }
     }
                private function hashChangeHandler():void

Reply via email to