You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by rg...@apache.org on 2007/03/08 23:32:20 UTC
svn commit: r516197 -
/struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/components/Set.java
Author: rgielen
Date: Thu Mar 8 14:32:20 2007
New Revision: 516197
URL: http://svn.apache.org/viewvc?view=rev&rev=516197
Log:
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.
Modified:
struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/components/Set.java
Modified: struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/components/Set.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/components/Set.java?view=diff&rev=516197&r1=516196&r2=516197
==============================================================================
--- struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/components/Set.java (original)
+++ struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/components/Set.java Thu Mar 8 14:32:20 2007
@@ -32,7 +32,9 @@
* <p>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).</P>
+ * readability improvement).</p>
+ * <p>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.</p>
*
* The scopes available are as follows :-
* <ul>
@@ -75,7 +77,7 @@
* </pre>
*
*/
-@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 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()) {