struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject svn commit: r1133044 - in /struts/struts2/trunk/core/src: main/java/org/apache/struts2/views/jsp/ui/AbstractUITag.java test/java/org/apache/struts2/views/jsp/ui/AnchorTest.java test/resources/org/apache/struts2/views/jsp/ui/Anchor-3.txt
Date Tue, 07 Jun 2011 15:18:58 GMT
Author: lukaszlenart
Date: Tue Jun  7 15:18:58 2011
New Revision: 1133044

URL: http://svn.apache.org/viewvc?rev=1133044&view=rev
Log:
WW-3644 - adds support for expression evaluation in dynamic attributes

Added:
    struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Anchor-3.txt
      - copied, changed from r1132139, struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Anchor-2.txt
Modified:
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/AbstractUITag.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/AnchorTest.java

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/AbstractUITag.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/AbstractUITag.java?rev=1133044&r1=1133043&r2=1133044&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/AbstractUITag.java
(original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/AbstractUITag.java
Tue Jun  7 15:18:58 2011
@@ -21,14 +21,13 @@
 
 package org.apache.struts2.views.jsp.ui;
 
-import java.util.HashMap;
-import java.util.Map;
+import org.apache.struts2.components.UIBean;
+import org.apache.struts2.views.jsp.ComponentTagSupport;
 
 import javax.servlet.jsp.JspException;
 import javax.servlet.jsp.tagext.DynamicAttributes;
-
-import org.apache.struts2.components.UIBean;
-import org.apache.struts2.views.jsp.ComponentTagSupport;
+import java.util.HashMap;
+import java.util.Map;
 
 
 /**
@@ -292,6 +291,11 @@ public abstract class AbstractUITag exte
     }
 
     public void setDynamicAttribute(String uri, String localName, Object value) throws JspException
{
-        dynamicAttributes.put(localName, value);
+        if (value != null && value instanceof String) {
+            dynamicAttributes.put(localName, findValue(value.toString()));
+        } else {
+            dynamicAttributes.put(localName, value);
+        }
     }
+
 }

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/AnchorTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/AnchorTest.java?rev=1133044&r1=1133043&r2=1133044&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/AnchorTest.java
(original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/AnchorTest.java
Tue Jun  7 15:18:58 2011
@@ -76,4 +76,22 @@ public class AnchorTest extends Abstract
 
         verify(AnchorTest.class.getResource("Anchor-2.txt"));
     }
+
+    public void testDynamicAttributeAsExpression() throws Exception {
+        TestAction testAction = (TestAction) action;
+        testAction.setFoo("bar");
+
+        AnchorTag tag = new AnchorTag();
+        tag.setPageContext(pageContext);
+
+        tag.setId("mylink");
+        tag.setHref("a");
+
+        tag.setDynamicAttribute("uri", "placeholder", "foo");
+
+        tag.doStartTag();
+        tag.doEndTag();
+
+        verify(AnchorTest.class.getResource("Anchor-3.txt"));
+    }
 }

Copied: struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Anchor-3.txt
(from r1132139, struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Anchor-2.txt)
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Anchor-3.txt?p2=struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Anchor-3.txt&p1=struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Anchor-2.txt&r1=1132139&r2=1133044&rev=1133044&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Anchor-2.txt
(original)
+++ struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Anchor-3.txt
Tue Jun  7 15:18:58 2011
@@ -1,5 +1,5 @@
 <a
  id="mylink"
  href="a"
- dynAttrName="dynAttrValue">
+ placeholder="bar">
 </a>



Mime
View raw message