You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-commits@xmlgraphics.apache.org by ca...@apache.org on 2006/03/15 07:12:32 UTC

svn commit: r385979 - /xmlgraphics/batik/branches/svg11/sources/org/apache/batik/script/rhino/WindowWrapper.java

Author: cam
Date: Tue Mar 14 22:12:30 2006
New Revision: 385979

URL: http://svn.apache.org/viewcvs?rev=385979&view=rev
Log:
1. Fixed window.prompt so that an exception isn't thrown when the prompt
   window is cancelled.

Modified:
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/script/rhino/WindowWrapper.java

Modified: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/script/rhino/WindowWrapper.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/script/rhino/WindowWrapper.java?rev=385979&r1=385978&r2=385979&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/script/rhino/WindowWrapper.java (original)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/script/rhino/WindowWrapper.java Tue Mar 14 22:12:30 2006
@@ -1,6 +1,6 @@
 /*
 
-   Copyright 1999-2003  The Apache Software Foundation 
+   Copyright 1999-2003,2006  The Apache Software Foundation 
 
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
@@ -360,22 +360,29 @@
         int len = args.length;
         WindowWrapper ww = (WindowWrapper)thisObj;
         Window window = ww.window;
-        switch (len) {
-        case 0:
-            return Context.toObject("", thisObj);
-
-        case 1:
-            String message =
-                (String)Context.toType(args[0], String.class);
-            return Context.toObject(window.prompt(message), thisObj);
+        Object result;
+        switch (args.length) {
+            case 0:
+                result = "";
+                break;
+            case 1:
+                String message =
+                    (String)Context.toType(args[0], String.class);
+                result = window.prompt(message);
+                break;
+            default:
+                message =
+                    (String)Context.toType(args[0], String.class);
+                String defVal =
+                    (String)Context.toType(args[1], String.class);
+                result = window.prompt(message, defVal);
+                break;
+        }
 
-        default:
-            message =
-                (String)Context.toType(args[0], String.class);
-            String defVal =
-                (String)Context.toType(args[1], String.class);
-            return Context.toObject(window.prompt(message, defVal), thisObj);
+        if (result == null) {
+            return null;
         }
+        return Context.toObject(result, thisObj);
     }
 
     /**