This repository has been archived by the owner on Feb 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
/
form.jsp
111 lines (100 loc) · 3.6 KB
/
form.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="s" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@ page session="false" %>
<c:if test="${!ajaxRequest}">
<html>
<head>
<title>forms | mvc-showcase</title>
<link href="<c:url value="/resources/form.css" />" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<c:url value="/resources/jquery/1.6/jquery.js" />"></script>
</head>
<body>
</c:if>
<div id="formsContent">
<h2>Forms</h2>
<p>
See the <code>org.springframework.samples.mvc.form</code> package for the @Controller code
</p>
<form:form id="form" method="post" modelAttribute="formBean" cssClass="cleanform">
<div class="header">
<h2>Form</h2>
<c:if test="${not empty message}">
<div id="message" class="success"><c:out value="${message}"/></div>
</c:if>
<s:bind path="*">
<c:if test="${status.error}">
<div id="message" class="error">Form has errors</div>
</c:if>
</s:bind>
</div>
<fieldset>
<legend>Personal Info</legend>
<form:label path="name">
Name <form:errors path="name" cssClass="error" />
</form:label>
<form:input path="name" />
<form:label path="age">
Age <form:errors path="age" cssClass="error" />
</form:label>
<form:input path="age" />
<form:label path="birthDate">
Birth Date (in form yyyy-mm-dd) <form:errors path="birthDate" cssClass="error" />
</form:label>
<form:input path="birthDate" />
<form:label path="phone">
Phone (in form (###) ###-####) <form:errors path="phone" cssClass="error" />
</form:label>
<form:input path="phone" />
<form:label path="currency">
Currency (in form $#.##) <form:errors path="currency" cssClass="error" />
</form:label>
<form:input path="currency" />
<form:label path="percent">
Percentage (in form ##%) <form:errors path="percent" cssClass="error" />
</form:label>
<form:input path="percent" />
</fieldset>
<fieldset>
<legend>Inquiry</legend>
<form:label path="inquiry">
Type (select one)
</form:label>
<form:select path="inquiry">
<form:option value="comment">Comment</form:option>
<form:option value="feedback">Feedback</form:option>
<form:option value="suggestion">Suggestion</form:option>
</form:select>
<form:label path="inquiryDetails">
Details
</form:label>
<form:textarea path="inquiryDetails" />
</fieldset>
<fieldset class="checkbox">
<legend>Request Additional Info</legend>
<label><form:checkbox path="additionalInfo[mvc]" value="true" />on Spring MVC</label>
<label><form:checkbox path="additionalInfo[java]" value="true" />on Java (4-ever)</label>
</fieldset>
<fieldset class="radio">
<legend>Subscribe to Newsletter?</legend>
<label><form:radiobutton path="subscribeNewsletter" value="true" />Yes</label>
<label><form:radiobutton path="subscribeNewsletter" value="false" /> No</label>
</fieldset>
<p><button type="submit">Submit</button></p>
</form:form>
<script type="text/javascript">
$(document).ready(function() {
$("#form").submit(function() {
$.post($(this).attr("action"), $(this).serialize(), function(html) {
$("#formsContent").replaceWith(html);
$('html, body').animate({ scrollTop: $("#message").offset().top }, 500);
});
return false;
});
});
</script>
</div>
<c:if test="${!ajaxRequest}">
</body>
</html>
</c:if>