struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jo...@apache.org
Subject [3/4] struts git commit: WW-4532 Javascript generated by s:doubleselect has global variables that can interfer with the rest of the app
Date Tue, 04 Aug 2015 20:02:45 GMT
WW-4532 Javascript generated by s:doubleselect has global variables that can interfer with
the rest of the app

- Fix problem with missing var for loop variable and possible mixed scope


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/3e1087a7
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/3e1087a7
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/3e1087a7

Branch: refs/heads/master
Commit: 3e1087a7fa1b2ee32ce7b9fc8d8f289f2fd7d2fa
Parents: 0469947
Author: Johannes Geppert <jogep@apache.org>
Authored: Tue Aug 4 22:02:24 2015 +0200
Committer: Johannes Geppert <jogep@apache.org>
Committed: Tue Aug 4 22:02:24 2015 +0200

----------------------------------------------------------------------
 core/src/main/resources/template/simple/debug.ftl    |  6 +++---
 .../main/resources/template/simple/doubleselect.ftl  | 15 ++++++---------
 .../apache/struts2/views/jsp/ui/DoubleSelect-1.txt   |  9 +++++----
 .../apache/struts2/views/jsp/ui/DoubleSelect-2.txt   |  9 +++++----
 .../apache/struts2/views/jsp/ui/DoubleSelect-3.txt   |  9 +++++----
 .../apache/struts2/views/jsp/ui/DoubleSelect-4.txt   |  9 +++++----
 6 files changed, 29 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/3e1087a7/core/src/main/resources/template/simple/debug.ftl
----------------------------------------------------------------------
diff --git a/core/src/main/resources/template/simple/debug.ftl b/core/src/main/resources/template/simple/debug.ftl
index da40aeb..492ee76 100644
--- a/core/src/main/resources/template/simple/debug.ftl
+++ b/core/src/main/resources/template/simple/debug.ftl
@@ -42,12 +42,12 @@
     table.debugTable th, table.debugTable td {padding:2px;}
 -->
 </style>
-<p />
+<br>
 
 <a href="#" onclick="toggleDebug('<#if parameters.id?if_exists != "">${parameters.id?html}<#else>debug</#if>');return
false;">[Debug]</a>
 <div style="display:none" id="<#if parameters.id?if_exists != "">${parameters.id?html}<#else>debug</#if>">
 <h2>Struts ValueStack Debug</h2>
-<p />
+<br>
 
 <h3>Value Stack Contents</h3>
 <table class="debugTable">
@@ -69,7 +69,7 @@
         </#list>
     </#list>
 </table>
-<p />
+<br>
 
 <h3>Stack Context</h3>
 <i>These items are available using the #key notation</i>

http://git-wip-us.apache.org/repos/asf/struts/blob/3e1087a7/core/src/main/resources/template/simple/doubleselect.ftl
----------------------------------------------------------------------
diff --git a/core/src/main/resources/template/simple/doubleselect.ftl b/core/src/main/resources/template/simple/doubleselect.ftl
index 313eb16..5485755 100644
--- a/core/src/main/resources/template/simple/doubleselect.ftl
+++ b/core/src/main/resources/template/simple/doubleselect.ftl
@@ -75,8 +75,9 @@
 <script type="text/javascript">
     <#assign itemCount = startCount/>
     var ${parameters.id}Group = new Array(${parameters.listSize} + ${startCount});
-    for (i = 0; i < (${parameters.listSize} + ${startCount}); i++)
-        ${parameters.id}Group[i] = new Array();
+    for (var i = 0; i < (${parameters.listSize} + ${startCount}); i++) {
+        ${parameters.id}Group[i] = [];
+    }
 
     <@s.iterator value="parameters.list">
         <#if parameters.listKey??>
@@ -164,19 +165,15 @@
     ${parameters.id}Redirect(${redirectTo});
     function ${parameters.id}Redirect(x) {
         var selected = false;
-        for (m = ${parameters.id}Temp.options.length - 1; m >= 0; m--) {
+        for (var m = ${parameters.id}Temp.options.length - 1; m >= 0; m--) {
             ${parameters.id}Temp.remove(m);
         }
 
-        for (i = 0; i < ${parameters.id}Group[x].length; i++) {
+        for (var i = 0; i < ${parameters.id}Group[x].length; i++) {
             ${parameters.id}Temp.options[i] = new Option(${parameters.id}Group[x][i].text,
${parameters.id}Group[x][i].value);
         <#if parameters.doubleNameValue??>
             <#if parameters.doubleMultiple??>
-                for (j = 0; j < ${parameters.doubleNameValue}.
-                length;
-                j++
-            )
-                {
+                for (var j = 0; j < ${parameters.doubleNameValue}.length; j++) {
                     if (${parameters.id}Temp.options[i].value == ${parameters.doubleNameValue?js_string}[j])
{
                         ${parameters.id}Temp.options[i].selected = true;
                         selected = true;

http://git-wip-us.apache.org/repos/asf/struts/blob/3e1087a7/core/src/test/resources/org/apache/struts2/views/jsp/ui/DoubleSelect-1.txt
----------------------------------------------------------------------
diff --git a/core/src/test/resources/org/apache/struts2/views/jsp/ui/DoubleSelect-1.txt b/core/src/test/resources/org/apache/struts2/views/jsp/ui/DoubleSelect-1.txt
index e536c56..e4a6db1 100644
--- a/core/src/test/resources/org/apache/struts2/views/jsp/ui/DoubleSelect-1.txt
+++ b/core/src/test/resources/org/apache/struts2/views/jsp/ui/DoubleSelect-1.txt
@@ -10,8 +10,9 @@
 </select>
 <script type="text/javascript">
     var fooGroup = new Array(2 + 0);
-    for (i = 0; i < (2 + 0); i++)
-    fooGroup[i] = new Array();
+    for (var i = 0; i < (2 + 0); i++) {
+    fooGroup[i] = [];
+    }
 
     fooGroup[0][0] = new Option("Antwerp", "AN");
     fooGroup[0][1] = new Option("Gent", "GN");
@@ -24,11 +25,11 @@
 
     function fooRedirect(x) {
     	var selected = false;
-        for (m = fooTemp.options.length - 1; m >= 0; m--) {
+        for (var m = fooTemp.options.length - 1; m >= 0; m--) {
             fooTemp.remove(m);
         }
 
-        for (i = 0; i < fooGroup[x].length; i++) {
+        for (var i = 0; i < fooGroup[x].length; i++) {
             fooTemp.options[i] = new Option(fooGroup[x][i].text, fooGroup[x][i].value);
         }
 

http://git-wip-us.apache.org/repos/asf/struts/blob/3e1087a7/core/src/test/resources/org/apache/struts2/views/jsp/ui/DoubleSelect-2.txt
----------------------------------------------------------------------
diff --git a/core/src/test/resources/org/apache/struts2/views/jsp/ui/DoubleSelect-2.txt b/core/src/test/resources/org/apache/struts2/views/jsp/ui/DoubleSelect-2.txt
index 87fa10d..b2e8552 100644
--- a/core/src/test/resources/org/apache/struts2/views/jsp/ui/DoubleSelect-2.txt
+++ b/core/src/test/resources/org/apache/struts2/views/jsp/ui/DoubleSelect-2.txt
@@ -10,8 +10,9 @@
 </select>
 <script type="text/javascript">
     var fooGroup = new Array(2 + 0);
-    for (i = 0; i < (2 + 0); i++)
-    fooGroup[i] = new Array();
+    for (var i = 0; i < (2 + 0); i++) {
+    fooGroup[i] = [];
+    }
 
     fooGroup[0][0] = new Option("Antwerp", "AN");
     fooGroup[0][1] = new Option("Gent", "GN");
@@ -24,11 +25,11 @@
 
     function fooRedirect(x) {
     	var selected = false;
-        for (m = fooTemp.options.length - 1; m >= 0; m--) {
+        for (var m = fooTemp.options.length - 1; m >= 0; m--) {
             fooTemp.remove(m);
         }
 
-        for (i = 0; i < fooGroup[x].length; i++) {
+        for (var i = 0; i < fooGroup[x].length; i++) {
             fooTemp.options[i] = new Option(fooGroup[x][i].text, fooGroup[x][i].value);
             	if (fooTemp.options[i].value == 'BOR') {
             		fooTemp.options[i].selected = true;

http://git-wip-us.apache.org/repos/asf/struts/blob/3e1087a7/core/src/test/resources/org/apache/struts2/views/jsp/ui/DoubleSelect-3.txt
----------------------------------------------------------------------
diff --git a/core/src/test/resources/org/apache/struts2/views/jsp/ui/DoubleSelect-3.txt b/core/src/test/resources/org/apache/struts2/views/jsp/ui/DoubleSelect-3.txt
index 69f0923..66f0c5b 100644
--- a/core/src/test/resources/org/apache/struts2/views/jsp/ui/DoubleSelect-3.txt
+++ b/core/src/test/resources/org/apache/struts2/views/jsp/ui/DoubleSelect-3.txt
@@ -10,8 +10,9 @@
 </select>
 <script type="text/javascript">
     var foo_barGroup = new Array(2 + 0);
-    for (i = 0; i < (2 + 0); i++)
-    foo_barGroup[i] = new Array();
+    for (var i = 0; i < (2 + 0); i++) {
+    foo_barGroup[i] = [];
+    }
 
     foo_barGroup[0][0] = new Option("Antwerp", "AN");
     foo_barGroup[0][1] = new Option("Gent", "GN");
@@ -24,11 +25,11 @@
 
     function foo_barRedirect(x) {
     	var selected = false;
-        for (m = foo_barTemp.options.length - 1; m >= 0; m--) {
+        for (var m = foo_barTemp.options.length - 1; m >= 0; m--) {
             foo_barTemp.remove(m);
         }
 
-        for (i = 0; i < foo_barGroup[x].length; i++) {
+        for (var i = 0; i < foo_barGroup[x].length; i++) {
             foo_barTemp.options[i] = new Option(foo_barGroup[x][i].text, foo_barGroup[x][i].value);
         }
 

http://git-wip-us.apache.org/repos/asf/struts/blob/3e1087a7/core/src/test/resources/org/apache/struts2/views/jsp/ui/DoubleSelect-4.txt
----------------------------------------------------------------------
diff --git a/core/src/test/resources/org/apache/struts2/views/jsp/ui/DoubleSelect-4.txt b/core/src/test/resources/org/apache/struts2/views/jsp/ui/DoubleSelect-4.txt
index 74cde90..93cdddb 100644
--- a/core/src/test/resources/org/apache/struts2/views/jsp/ui/DoubleSelect-4.txt
+++ b/core/src/test/resources/org/apache/struts2/views/jsp/ui/DoubleSelect-4.txt
@@ -10,8 +10,9 @@
 </select>
 <script type="text/javascript">
     var fooGroup = new Array(2 + 0);
-    for (i = 0; i < (2 + 0); i++)
-    fooGroup[i] = new Array();
+    for (var i = 0; i < (2 + 0); i++) {
+    fooGroup[i] = [];
+    }
 
     fooGroup[0][0] = new Option("Antwerp", "AN");
     fooGroup[0][1] = new Option("Gent", "GN");
@@ -24,11 +25,11 @@
 
     function fooRedirect(x) {
     	var selected = false;
-        for (m = fooTemp.options.length - 1; m >= 0; m--) {
+        for (var m = fooTemp.options.length - 1; m >= 0; m--) {
             fooTemp.remove(m);
         }
 
-        for (i = 0; i < fooGroup[x].length; i++) {
+        for (var i = 0; i < fooGroup[x].length; i++) {
             fooTemp.options[i] = new Option(fooGroup[x][i].text, fooGroup[x][i].value);
         }
 


Mime
View raw message