mirror of
https://github.com/apache/struts.git
synced 2026-08-31 19:35:40 +00:00
WW-2951 Add a default "name" to form, when it is not set (same as the "id")
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@766376 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -36,6 +36,7 @@ import com.opensymphony.xwork2.validator.Validator;
|
|||||||
import org.apache.struts2.StrutsConstants;
|
import org.apache.struts2.StrutsConstants;
|
||||||
import org.apache.struts2.views.annotations.StrutsTag;
|
import org.apache.struts2.views.annotations.StrutsTag;
|
||||||
import org.apache.struts2.views.annotations.StrutsTagAttribute;
|
import org.apache.struts2.views.annotations.StrutsTagAttribute;
|
||||||
|
import org.apache.commons.lang.xwork.StringUtils;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
@@ -153,28 +154,18 @@ public class Form extends ClosingUIBean {
|
|||||||
*/
|
*/
|
||||||
protected void evaluateExtraParams() {
|
protected void evaluateExtraParams() {
|
||||||
super.evaluateExtraParams();
|
super.evaluateExtraParams();
|
||||||
|
|
||||||
//boolean isAjax = "ajax".equalsIgnoreCase(this.theme);
|
|
||||||
|
|
||||||
if (validate != null) {
|
if (validate != null) {
|
||||||
addParameter("validate", findValue(validate, Boolean.class));
|
addParameter("validate", findValue(validate, Boolean.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate the action and namespace
|
if (name == null) {
|
||||||
/*String action = null;
|
//make the name the same as the id
|
||||||
if (this.action != null) {
|
String id = (String) getParameters().get("id");
|
||||||
// if it isn't specified, we'll make somethig up
|
if (StringUtils.isNotEmpty(id)) {
|
||||||
action = findString(this.action);
|
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) {
|
if (onsubmit != null) {
|
||||||
addParameter("onsubmit", findString(onsubmit));
|
addParameter("onsubmit", findString(onsubmit));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ public class FormTagTest extends AbstractUITagTest {
|
|||||||
tag.setEnctype("myEncType");
|
tag.setEnctype("myEncType");
|
||||||
tag.setTitle("mytitle");
|
tag.setTitle("mytitle");
|
||||||
tag.setOnsubmit("submitMe()");
|
tag.setOnsubmit("submitMe()");
|
||||||
|
tag.setId("myid");
|
||||||
|
|
||||||
tag.doStartTag();
|
tag.doStartTag();
|
||||||
tag.doEndTag();
|
tag.doEndTag();
|
||||||
@@ -137,6 +138,28 @@ public class FormTagTest extends AbstractUITagTest {
|
|||||||
verify(FormTag.class.getResource("Formtag-1.txt"));
|
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
|
* This test with form tag validation enabled. Js validation script will appear
|
||||||
* cause action submited by the form is intercepted by validation interceptor which
|
* cause action submited by the form is intercepted by validation interceptor which
|
||||||
|
|||||||
@@ -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 class="wwFormTable">
|
||||||
</table>
|
</table>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -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>
|
||||||
@@ -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 class="wwFormTable">
|
||||||
</table>
|
</table>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -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 class="wwFormTable">
|
||||||
</table>
|
</table>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
Reference in New Issue
Block a user