-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnew.jsp
128 lines (115 loc) · 4.44 KB
/
new.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="spring" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page import="java.util.List" %>
<%@ page import="uma.taw.ubayspring.dto.products.ProductCategoryDTO" %>
<%--
Created by IntelliJ IDEA.
Author: Francisco Javier Hernández
Date: 28/3/22
Time: 19:44
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3"
crossorigin="anonymous">
<title><spring:message key="product.new.header"/></title>
</head>
<body>
<%
List<ProductCategoryDTO> categoryList = (List<ProductCategoryDTO>) request.getAttribute("categoryList");
%>
<jsp:include page="../../components/navbar.jsp"/>
<%--@elvariable id="productModel" type="uma.taw.ubayspring.dto.products.ProductForm.ProductFormParamsDTO"--%>
<form:form
method="post"
enctype="multipart/form-data"
action="${pageContext.request.contextPath}/product/new"
modelAttribute="productModel"
>
<div class="d-flex flex-row m-auto" style="width: 1000px">
<%-- BLOQUE I - Imagen --%>
<div class="d-flex flex-column p-2">
<div class="p-2">
<img id="output" style="height: auto; width: 500px;"/>
</div>
<div class="form-group mb-3 w-75 p-2">
<label for="img" class="form-label"><spring:message key="product.new.uploadimage"/></label>
<form:input
type="file"
accept="image/*"
class="form-control"
id="img"
onchange="loadFile(event)"
path="image"/>
</div>
</div>
<%-- BLOQUE II - Resto --%>
<div class="d-flex flex-column p-2">
<%-- Titulo --%>
<div class="form-group w-75 p-2">
<label for="tit"><spring:message key="product.title"/>:</label>
<form:input
type="text"
id="tit"
class="form-control"
path="title"
required="true"
/>
</div>
<%-- Descripcion --%>
<div class="p-2">
<label for="desc"><spring:message key="description"/>:</label>
<form:textarea
id="desc"
class="form-control"
rows="4"
cols="50"
path="description"
/>
</div>
<%-- Precio --%>
<div class="p-2">
<label for="precio"><spring:message key="product.update.price"/></label>
<form:input
type="number"
min="0"
id="precio"
class="form-control"
path="price"
required="true"/>
</div>
<%-- Categoria --%>
<div class="p-2">
<label><spring:message key="product.index.filter.category"/></label>
<form:select name="category" path="category">
<form:options items="<%=categoryList%>" itemValue="id" itemLabel="name"/>
</form:select>
</div>
<%-- Submit --%>
<div class="p-2">
<div class="d-flex flex-row p-2">
<div class="p-2">
<spring:message key="confirm" var="confirm"/>
<input class="btn btn-primary p-2" type="submit" value="${confirm}"/>
</div>
<div class="p-2">
<a href="${pageContext.request.contextPath}/product" class="btn btn-secondary p-2"><spring:message key="cancel"/></a>
</div>
</div>
</div>
</div>
</div>
</form:form>
</body>
<script>
var loadFile = function (event) {
var image = document.getElementById('output');
image.src = URL.createObjectURL(event.target.files[0]);
image.alt = event.target.files[0].name
};
</script>
</html>