From 209965eff06b2fc805897805ee0d184ca629b016 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ren=C3=A9=20Gielen?=
Date: Thu, 8 Mar 2007 22:32:20 +0000
Subject: [PATCH] WW-1768: Applied Oleg Gorobets' patch to make Set tag support
JSP body as String value to set. Added also some words of documentation of
this new feature.
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@516197 13f79535-47bb-0310-9956-ffa450edef68
---
.../org/apache/struts2/components/Set.java | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/core/src/main/java/org/apache/struts2/components/Set.java b/core/src/main/java/org/apache/struts2/components/Set.java
index b70cbb0e7..942b8b0af 100644
--- a/core/src/main/java/org/apache/struts2/components/Set.java
+++ b/core/src/main/java/org/apache/struts2/components/Set.java
@@ -32,7 +32,9 @@ import com.opensymphony.xwork2.util.ValueStack;
* The set tag assigns a value to a variable in a specified scope. It is useful when you wish to assign a variable to a
* complex expression and then simply reference that variable each time rather than the complex expression. This is
* useful in both cases: when the complex expression takes time (performance improvement) or is hard to read (code
- * readability improvement).
+ * readability improvement).
+ * If the tag is used with body content, the evaluation of the value parameter is omitted. Instead, the String to
+ * which the body eveluates is set as value for the scoped variable.
*
* The scopes available are as follows :-
*
@@ -75,7 +77,7 @@ import com.opensymphony.xwork2.util.ValueStack;
*
*
*/
-@StrutsTag(name="set", tldBodyContent="empty", tldTagClass="org.apache.struts2.views.jsp.SetTag", description="Assigns a value to a variable in a specified scope")
+@StrutsTag(name="set", tldBodyContent="JSP", tldTagClass="org.apache.struts2.views.jsp.SetTag", description="Assigns a value to a variable in a specified scope")
public class Set extends Component {
protected String name;
protected String scope;
@@ -88,11 +90,18 @@ public class Set extends Component {
public boolean end(Writer writer, String body) {
ValueStack stack = getStack();
+ Object o;
if (value == null) {
- value = "top";
+ if (body!=null && !body.equals("")) {
+ o = body;
+ } else {
+ o = findValue("top");
+ }
+ } else {
+ o = findValue(value);
}
-
- Object o = findValue(value);
+
+ body="";
String name;
if (altSyntax()) {