Author: musachy Date: Thu Jun 14 11:53:25 2007 New Revision: 547359 URL: http://svn.apache.org/viewvc?view=rev&rev=547359 Log: WW-1891 tags that insert values into the value stack should use "name" attribute to specify the name
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Set.java struts/struts2/trunk/core/src/site/resources/tags/set.html struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/SetTagTest.java 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=547359&r1=547358&r2=547359 ============================================================================== --- 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 Thu Jun 14 11:53:25 2007 @@ -56,7 +56,7 @@ * * <ul> * - * <li>id (String): The name of the new variable that is assigned the value of <i>value</i></li> + * <li>name* (String): The name of the new variable that is assigned the value of <i>value</i></li> * * <li>value (Object): The value that is assigned to the variable named <i>name</i></li> * @@ -71,7 +71,7 @@ * * <pre> * <!-- START SNIPPET: example --> - * <s:set id="personName" value="person.name"/> + * <s:set name="personName" value="person.name"/> * Hello, <s:property value="#personName"/>. How are you? * <!-- END SNIPPET: example --> * </pre> @@ -103,26 +103,36 @@ body=""; - //no need to throw an error, the id is required on the TLD + 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['" + id + "']", o); + stack.setValue("#application['" + name + "']", o); } else if ("session".equalsIgnoreCase(scope)) { - stack.setValue("#session['" + id + "']", o); + stack.setValue("#session['" + name + "']", o); } else if ("request".equalsIgnoreCase(scope)) { - stack.setValue("#request['" + id + "']", o); + stack.setValue("#request['" + name + "']", o); } else if ("page".equalsIgnoreCase(scope)) { - stack.setValue("#attr['" + id + "']", o, false); + stack.setValue("#attr['" + name + "']", o, false); } else { - stack.getContext().put(id, o); - stack.setValue("#attr['" + id + "']", o, false); + stack.getContext().put(name, o); + stack.setValue("#attr['" + name + "']", o, false); } return super.end(writer, body); } - @StrutsTagAttribute(description="Deprecated. Use 'id' instead") + @StrutsTagAttribute(description=" The name of the new variable that is assigned the value of <i>value</i>", required=true) public void setName(String name) { - super.setId(name); + this.name = name; } @StrutsTagAttribute(description="The scope in which to assign the variable. Can be <b>application</b>" + @@ -134,10 +144,5 @@ @StrutsTagAttribute(description="The value that is assigned to the variable named <i>name</i>") public void setValue(String value) { this.value = value; - } - - @StrutsTagAttribute(description="The name of the new variable that is assigned the value of <i>value</i>", required=true) - public void setId(String id) { - super.setId(id); } } 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=547359&r1=547358&r2=547359 ============================================================================== --- struts/struts2/trunk/core/src/site/resources/tags/set.html (original) +++ struts/struts2/trunk/core/src/site/resources/tags/set.html Thu Jun 14 11:53:25 2007 @@ -29,19 +29,19 @@ </tr> <tr> <td align="left" valign="top">id</td> - <td align="left" valign="top"><strong>true</strong></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">The name of the new variable that is assigned the value of <i>value</i></td> + <td align="left" valign="top">id for referencing element. For UI and form tags it will be used as HTML id attribute</td> </tr> <tr> <td align="left" valign="top">name</td> - <td align="left" valign="top">false</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">Deprecated. Use 'id' instead</td> + <td align="left" valign="top"> The name of the new variable that is assigned the value of <i>value</i></td> </tr> <tr> <td align="left" valign="top">scope</td> Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/SetTagTest.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/SetTagTest.java?view=diff&rev=547359&r1=547358&r2=547359 ============================================================================== --- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/SetTagTest.java (original) +++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/SetTagTest.java Thu Jun 14 11:53:25 2007 @@ -40,17 +40,6 @@ assertEquals("chewie", servletContext.getAttribute("foo")); } - - public void testApplicationScopeUseId() throws JspException { - tag.setId("foo"); - tag.setValue("name"); - tag.setScope("application"); - tag.doStartTag(); - tag.doEndTag(); - - assertEquals("chewie", servletContext.getAttribute("foo")); - } - public void testPageScope() throws JspException { tag.setName("foo"); @@ -61,16 +50,6 @@ assertEquals("chewie", pageContext.getAttribute("foo")); } - - public void testPageScopeUseId() throws JspException { - tag.setId("foo"); - tag.setValue("name"); - tag.setScope("page"); - tag.doStartTag(); - tag.doEndTag(); - - assertEquals("chewie", pageContext.getAttribute("foo")); - } public void testRequestScope() throws JspException { tag.setName("foo"); @@ -80,15 +59,6 @@ tag.doEndTag(); assertEquals("chewie", request.getAttribute("foo")); } - - public void testRequestScopeUseId() throws JspException { - tag.setId("foo"); - tag.setValue("name"); - tag.setScope("request"); - tag.doStartTag(); - tag.doEndTag(); - assertEquals("chewie", request.getAttribute("foo")); - } public void testSessionScope() throws JspException { tag.setName("foo"); @@ -99,16 +69,6 @@ assertEquals("chewie", session.get("foo")); } - - public void testSessionScopeUseId() throws JspException { - tag.setId("foo"); - tag.setValue("name"); - tag.setScope("session"); - tag.doStartTag(); - tag.doEndTag(); - - assertEquals("chewie", session.get("foo")); - } public void testStrutsScope() throws JspException { tag.setName("foo"); @@ -117,24 +77,9 @@ tag.doEndTag(); assertEquals("chewie", context.get("foo")); } - - public void testStrutsScopeUseId() throws JspException { - tag.setId("foo"); - tag.setValue("name"); - tag.doStartTag(); - tag.doEndTag(); - assertEquals("chewie", context.get("foo")); - } public void testStrutsScope2() throws JspException { tag.setName("chewie"); - tag.doStartTag(); - tag.doEndTag(); - assertEquals(chewie, context.get("chewie")); - } - - public void testStrutsScope2UseId() throws JspException { - tag.setId("chewie"); tag.doStartTag(); tag.doEndTag(); assertEquals(chewie, context.get("chewie"));