Author: musachy
Date: Sat Apr 18 18:48:47 2009
New Revision: 766376
URL: http://svn.apache.org/viewvc?rev=766376&view=rev
Log:
WW-2951 Add a default "name" to form, when it is not set (same as the "id")
Added:
struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-25.txt
Modified:
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Form.java
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/FormTagTest.java
struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-1.txt
struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-4.txt
struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-7.txt
Modified:
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Form.java
URL:
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Form.java?rev=766376&r1=766375&r2=766376&view=diff
==============================================================================
---
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Form.java
(original)
+++
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Form.java
Sat Apr 18 18:48:47 2009
@@ -36,6 +36,7 @@
import org.apache.struts2.StrutsConstants;
import org.apache.struts2.views.annotations.StrutsTag;
import org.apache.struts2.views.annotations.StrutsTagAttribute;
+import org.apache.commons.lang.xwork.StringUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -153,28 +154,18 @@
*/
protected void evaluateExtraParams() {
super.evaluateExtraParams();
-
- //boolean isAjax = "ajax".equalsIgnoreCase(this.theme);
-
if (validate != null) {
addParameter("validate", findValue(validate, Boolean.class));
}
- // calculate the action and namespace
- /*String action = null;
- if (this.action != null) {
- // if it isn't specified, we'll make somethig up
- action = findString(this.action);
+ if (name == null) {
+ //make the name the same as the id
+ String id = (String) getParameters().get("id");
+ if (StringUtils.isNotEmpty(id)) {
+ addParameter("name", id);
+ }
}
- if (Dispatcher.getInstance().isPortletSupportActive() &&
PortletActionContext.isPortletRequest()) {
- evaluateExtraParamsPortletRequest(namespace, action);
- } else {
- String namespace = determineNamespace(this.namespace, getStack(),
- request);
- evaluateExtraParamsServletRequest(action, namespace, isAjax);
- }*/
-
if (onsubmit != null) {
addParameter("onsubmit", findString(onsubmit));
}
Modified:
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/FormTagTest.java
URL:
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/FormTagTest.java?rev=766376&r1=766375&r2=766376&view=diff
==============================================================================
---
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/FormTagTest.java
(original)
+++
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/FormTagTest.java
Sat Apr 18 18:48:47 2009
@@ -130,6 +130,7 @@
tag.setEnctype("myEncType");
tag.setTitle("mytitle");
tag.setOnsubmit("submitMe()");
+ tag.setId("myid");
tag.doStartTag();
tag.doEndTag();
@@ -137,6 +138,28 @@
verify(FormTag.class.getResource("Formtag-1.txt"));
}
+ public void testFormNoNameOrId() throws Exception {
+
+ request.setupGetServletPath("/testAction");
+
+ TestAction testAction = (TestAction) action;
+ testAction.setFoo("bar");
+
+ FormTag tag = new FormTag();
+ tag.setPageContext(pageContext);
+ tag.setMethod("post");
+ tag.setAcceptcharset("UTF-8");
+ tag.setAction("myAction");
+ tag.setEnctype("myEncType");
+ tag.setTitle("mytitle");
+ tag.setOnsubmit("submitMe()");
+
+ tag.doStartTag();
+ tag.doEndTag();
+
+ verify(FormTag.class.getResource("Formtag-25.txt"));
+ }
+
/**
* This test with form tag validation enabled. Js validation script will
appear
* cause action submited by the form is intercepted by validation
interceptor which
Modified:
struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-1.txt
URL:
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-1.txt?rev=766376&r1=766375&r2=766376&view=diff
==============================================================================
---
struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-1.txt
(original)
+++
struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-1.txt
Sat Apr 18 18:48:47 2009
@@ -1,4 +1,4 @@
-<form id="myAction" name="myForm" onsubmit="submitMe()" action="myAction"
method="post" enctype="myEncType" title="mytitle" accept-charset="UTF-8">
+<form id="myid" name="myForm" onsubmit="submitMe()" action="myAction"
method="post" enctype="myEncType" title="mytitle" accept-charset="UTF-8">
<table class="wwFormTable">
</table>
</form>
Added:
struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-25.txt
URL:
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-25.txt?rev=766376&view=auto
==============================================================================
---
struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-25.txt
(added)
+++
struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-25.txt
Sat Apr 18 18:48:47 2009
@@ -0,0 +1,4 @@
+<form id="myAction" name="myAction" onsubmit="submitMe()" action="myAction"
method="post" enctype="myEncType" title="mytitle" accept-charset="UTF-8">
+<table class="wwFormTable">
+</table>
+</form>
\ No newline at end of file
Modified:
struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-4.txt
URL:
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-4.txt?rev=766376&r1=766375&r2=766376&view=diff
==============================================================================
---
struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-4.txt
(original)
+++
struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-4.txt
Sat Apr 18 18:48:47 2009
@@ -1,4 +1,4 @@
-<form id="foo" action="/foo.jsp" method="post">
+<form id="foo" name="foo" action="/foo.jsp" method="post">
<table class="wwFormTable">
</table>
</form>
Modified:
struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-7.txt
URL:
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-7.txt?rev=766376&r1=766375&r2=766376&view=diff
==============================================================================
---
struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-7.txt
(original)
+++
struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-7.txt
Sat Apr 18 18:48:47 2009
@@ -1,4 +1,4 @@
-<form id="test" action="test.html" method="post">
+<form id="test" name="test" action="test.html" method="post">
<table class="wwFormTable">
</table>
</form>