Creating “Add Product” View and Controller

Creating Add Product Views and Controllers

We would like to make a views to insert a new product like this.

Snap 2014-01-02 at 10.23.36

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ page session="false"%>

<html>
<head>
<title>Add new product</title>
<link type="text/css"
	href="<c:url value="/resources/css/bootstrap.css"/>" rel="stylesheet" />
</head>
<body>
	<div class="container">
		<div class="row">
			<nav class="navbar navbar-default" role="navigation">
				<ul class="nav navbar-nav">
					<li><a href="<c:url value="/"/>">Home</a></li>
					<li><a href="<c:url value="/category/"/>">Category</a></li>
					<li><a href="<c:url value="/product/"/>">Product</a></li>
				</ul>
			</nav>
		</div>
	</div>


	<div class="container">
		<div class="row">
			<h1>Add new product</h1>

			<form:form action="addProductConfirm" method="post"
				commandName="productBean">
				<div class="form-group">
					<label for="productName">Product Name</label>
					<form:input path="productName" id="productName" />
				</div>
				<div class="form-group">
					<label for="productStock">Stock</label>
					<form:input path="productStock" id="productStock" />
				</div>
				<div class="form-group">
					<label for="productPrice">Price</label>
					<form:input path="productPrice" id="productPrice" />
				</div>

				<div class="form-group">
					<label for="productDescription">Description</label>
					<form:textarea path="productDescription" id="productDescription" />
				</div>

				<div class="form-group">
					<label for="category">Category</label>
					<form:select path="category" items="${categories}"
						itemLabel="categoryName" itemValue="categoryId">
					</form:select>
				</div>

				<div class="form-group">
					<br />
					<button type="submit" class="btn btn-default btn-success">Submit</button>
				</div>
			</form:form>
		</div>
	</div>
</body>
</html>

Continue reading

Advertisements