You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by mu...@apache.org on 2007/07/07 22:30:05 UTC
svn commit: r554257 - in /struts/struts2/trunk/core/src:
main/java/org/apache/struts2/components/Set.java
main/java/org/apache/struts2/views/jsp/SetTag.java
site/resources/tags/set.html
Author: musachy
Date: Sat Jul 7 13:30:04 2007
New Revision: 554257
URL: http://svn.apache.org/viewvc?view=rev&rev=554257
Log:
WW-2027 Tags that push values into the value stack should use the "var" attribute to specify the name of the variable
* Deprecate 'name' on 'set', use 'var' instead
Modified:
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Set.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/SetTag.java
struts/struts2/trunk/core/src/site/resources/tags/set.html
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Set.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Set.java?view=diff&rev=554257&r1=554256&r2=554257
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Set.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Set.java Sat Jul 7 13:30:04 2007
@@ -78,8 +78,7 @@
*
*/
@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;
+public class Set extends ContextBean {
protected String scope;
protected String value;
@@ -92,47 +91,41 @@
Object o;
if (value == null) {
- if (body!=null && !body.equals("")) {
- o = body;
- } else {
- o = findValue("top");
- }
+ if (body != null && !body.equals("")) {
+ o = body;
+ } else {
+ o = findValue("top");
+ }
} else {
- o = findValue(value);
+ o = findValue(value);
}
body="";
-
- String name;
- if (altSyntax()) {
- name = findString(this.name, "name", "Name is required");
- } else {
- name = this.name;
-
- if (this.name == null) {
- throw fieldError("name", "Name is required", null);
- }
- }
-
+
if ("application".equalsIgnoreCase(scope)) {
- stack.setValue("#application['" + name + "']", o);
+ stack.setValue("#application['" + getVar() + "']", o);
} else if ("session".equalsIgnoreCase(scope)) {
- stack.setValue("#session['" + name + "']", o);
+ stack.setValue("#session['" + getVar() + "']", o);
} else if ("request".equalsIgnoreCase(scope)) {
- stack.setValue("#request['" + name + "']", o);
+ stack.setValue("#request['" + getVar() + "']", o);
} else if ("page".equalsIgnoreCase(scope)) {
- stack.setValue("#attr['" + name + "']", o, false);
+ stack.setValue("#attr['" + getVar() + "']", o, false);
} else {
- stack.getContext().put(name, o);
- stack.setValue("#attr['" + name + "']", o, false);
+ stack.getContext().put(getVar(), o);
+ stack.setValue("#attr['" + getVar() + "']", o, false);
}
return super.end(writer, body);
}
- @StrutsTagAttribute(description=" The name of the new variable that is assigned the value of <i>value</i>", required=true)
+ @StrutsTagAttribute(description="Name used to reference the value pushed into the Value Stack", required=true)
+ public void setVar(String var) {
+ super.setVar(var);
+ }
+
+ @StrutsTagAttribute(description="Deprecated. Use 'var' instead", required=true)
public void setName(String name) {
- this.name = name;
+ setVar(name);
}
@StrutsTagAttribute(description="The scope in which to assign the variable. Can be <b>application</b>" +
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/SetTag.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/SetTag.java?view=diff&rev=554257&r1=554256&r2=554257
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/SetTag.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/SetTag.java Sat Jul 7 13:30:04 2007
@@ -32,11 +32,10 @@
/**
* @see Set
*/
-public class SetTag extends ComponentTagSupport {
+public class SetTag extends ContextBeanTag {
private static final long serialVersionUID = -5074213926790716974L;
- protected String name;
protected String scope;
protected String value;
@@ -48,13 +47,12 @@
super.populateParams();
Set set = (Set) component;
- set.setName(name);
set.setScope(scope);
set.setValue(value);
}
public void setName(String name) {
- this.name = name;
+ setVar(name);
}
public void setScope(String scope) {
Modified: struts/struts2/trunk/core/src/site/resources/tags/set.html
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/site/resources/tags/set.html?view=diff&rev=554257&r1=554256&r2=554257
==============================================================================
--- struts/struts2/trunk/core/src/site/resources/tags/set.html (original)
+++ struts/struts2/trunk/core/src/site/resources/tags/set.html Sat Jul 7 13:30:04 2007
@@ -28,12 +28,20 @@
<th align="left" valign="top"><h4>Description</h4></th>
</tr>
<tr>
+ <td align="left" valign="top">id</td>
+ <td align="left" valign="top">false</td>
+ <td align="left" valign="top"></td>
+ <td align="left" valign="top">true</td>
+ <td align="left" valign="top">String</td>
+ <td align="left" valign="top">Deprecated. Use 'var' instead</td>
+ </tr>
+ <tr>
<td align="left" valign="top">name</td>
<td align="left" valign="top"><strong>true</strong></td>
<td align="left" valign="top"></td>
<td align="left" valign="top">true</td>
<td align="left" valign="top">String</td>
- <td align="left" valign="top"> The name of the new variable that is assigned the value of <i>value</i></td>
+ <td align="left" valign="top">Deprecated. Use 'var' instead</td>
</tr>
<tr>
<td align="left" valign="top">scope</td>
@@ -50,6 +58,14 @@
<td align="left" valign="top">true</td>
<td align="left" valign="top">String</td>
<td align="left" valign="top">The value that is assigned to the variable named <i>name</i></td>
+ </tr>
+ <tr>
+ <td align="left" valign="top">var</td>
+ <td align="left" valign="top"><strong>true</strong></td>
+ <td align="left" valign="top"></td>
+ <td align="left" valign="top">true</td>
+ <td align="left" valign="top">String</td>
+ <td align="left" valign="top">Name used to reference the value pushed into the Value Stack</td>
</tr>
</table>
<!-- END SNIPPET: tagattributes -->