struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From musa...@apache.org
Subject svn commit: r751799 - in /struts/struts2/trunk/core/src: main/java/org/apache/struts2/components/ test/java/org/apache/struts2/views/jsp/ui/ test/resources/org/apache/struts2/views/jsp/ui/
Date Mon, 09 Mar 2009 19:28:21 GMT
Author: musachy
Date: Mon Mar  9 19:28:20 2009
New Revision: 751799

URL: http://svn.apache.org/viewvc?rev=751799&view=rev
Log:
WW-3029 Fix backward compatible problem in the Label tag

Added:
    struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Label-4.txt
    struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Label-5.txt
Modified:
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Label.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/LabelTest.java
    struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Label-2.txt

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Label.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Label.java?rev=751799&r1=751798&r2=751799&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Label.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Label.java Mon Mar
 9 19:28:20 2009
@@ -84,9 +84,12 @@
         if (value != null) {
             addParameter("nameValue", findString(value));
         } else if (key != null) {
-            // get the label from a TextProvider (default value is the key)
-            String providedLabel = TextProviderHelper.getText(key, key, stack);
-            addParameter("nameValue", providedLabel);
+            Object nameValue = parameters.get("nameValue");
+            if (nameValue == null || nameValue.toString().length() == 0) {
+                // get the label from a TextProvider (default value is the key)
+                String providedLabel = TextProviderHelper.getText(key, key, stack);
+                addParameter("nameValue", providedLabel);
+            }
         } else if (name != null) {
             String expr = completeExpressionIfAltSyntax(name);
             addParameter("nameValue", findString(expr));

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/LabelTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/LabelTest.java?rev=751799&r1=751798&r2=751799&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/LabelTest.java
(original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/LabelTest.java
Mon Mar  9 19:28:20 2009
@@ -97,7 +97,7 @@
         tag.doStartTag();
         tag.doEndTag();
 
-        verify(LabelTest.class.getResource("Label-2.txt"));
+        verify(LabelTest.class.getResource("Label-5.txt"));
     }
 
     public void testGenericSimple() throws Exception {
@@ -110,7 +110,7 @@
         verifyGenericProperties(tag, "xhtml", null);
     }
 
-    public void testWithKey() throws Exception {
+    public void testWithKeyNoValueFromStack() throws Exception {
         TestAction testAction = (TestAction) action;
         final String key = "labelKey";
         final String value = "baz";
@@ -122,7 +122,7 @@
         tag.setPageContext(pageContext);
         tag.setLabel("mylabel");
         tag.setFor("for");
-        tag.setName("foo");
+        tag.setName("foo2");
         tag.setKey(key);
 
         tag.doStartTag();
@@ -131,4 +131,25 @@
         verify(LabelTest.class.getResource("Label-2.txt"));
     }
 
+     public void testWithKeyValueFromStack() throws Exception {
+        TestAction testAction = (TestAction) action;
+        final String key = "labelKey";
+        final String value = "baz";
+        testAction.setText(key, value);
+
+        testAction.setFoo("output");
+
+        LabelTag tag = new LabelTag();
+        tag.setPageContext(pageContext);
+        tag.setLabel("mylabel");
+        tag.setFor("for");
+        tag.setName("foo");
+        tag.setKey(key);
+
+        tag.doStartTag();
+        tag.doEndTag();
+
+        verify(LabelTest.class.getResource("Label-4.txt"));
+    }
+
 }

Modified: struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Label-2.txt
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Label-2.txt?rev=751799&r1=751798&r2=751799&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Label-2.txt
(original)
+++ struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Label-2.txt
Mon Mar  9 19:28:20 2009
@@ -1,4 +1,4 @@
 <tr>
-    <td class="tdLabel"><label for="foo" class="label">mylabel:</label></td>
-    <td><label id="foo" for="for">baz</label></td>
+    <td class="tdLabel"><label for="foo2" class="label">mylabel:</label></td>
+    <td><label id="foo2" for="for">baz</label></td>
 </tr>

Added: struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Label-4.txt
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Label-4.txt?rev=751799&view=auto
==============================================================================
--- struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Label-4.txt
(added)
+++ struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Label-4.txt
Mon Mar  9 19:28:20 2009
@@ -0,0 +1,4 @@
+<tr>
+    <td class="tdLabel"><label for="foo" class="label">mylabel:</label></td>
+    <td><label id="foo" for="for">output</label></td>
+</tr>
\ No newline at end of file

Added: struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Label-5.txt
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Label-5.txt?rev=751799&view=auto
==============================================================================
--- struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Label-5.txt
(added)
+++ struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Label-5.txt
Mon Mar  9 19:28:20 2009
@@ -0,0 +1,4 @@
+<tr>
+    <td class="tdLabel"><label for="foo" class="label">mylabel:</label></td>
+    <td><label id="foo" for="for">baz</label></td>
+</tr>
\ No newline at end of file



Mime
View raw message