Skip to content

Commit e04ef7d

Browse files
committed
2 2 HW1 optional
1 parent d840c6a commit e04ef7d

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package ru.javawebinar.topjava.repository;
2+
3+
import ru.javawebinar.topjava.model.Meal;
4+
5+
import java.util.Collection;
6+
/**/
7+
public interface MealRepository {
8+
Meal save(Meal meal);
9+
10+
void delete(int id);
11+
12+
Meal get(int id);
13+
14+
Collection<Meal> getAll();
15+
}

src/main/webapp/mealForm.jsp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
2+
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
3+
4+
<html>
5+
<head>
6+
<title>Meal</title>
7+
<style>
8+
dl {
9+
background: none repeat scroll 0 0 #FAFAFA;
10+
margin: 8px 0;
11+
padding: 0;
12+
}
13+
14+
dt {
15+
display: inline-block;
16+
width: 170px;
17+
}
18+
19+
dd {
20+
display: inline-block;
21+
margin-left: 8px;
22+
vertical-align: top;
23+
}
24+
</style>
25+
</head>
26+
<body>
27+
<section>
28+
<h3><a href="index.html">Home</a></h3>
29+
<h2>${param.action == 'create' ? 'Create meal' : 'Edit meal'}</h2>
30+
<hr>
31+
<jsp:useBean id="meal" type="ru.javawebinar.topjava.model.Meal" scope="request"/>
32+
<form method="post" action="meals">
33+
<input type="hidden" name="id" value="${meal.id}">
34+
<dl>
35+
<dt>DateTime:</dt>
36+
<dd><input type="datetime-local" value="${meal.dateTime}" name="dateTime" required></dd>
37+
</dl>
38+
<dl>
39+
<dt>Description:</dt>
40+
<dd><input type="text" value="${meal.description}" size=40 name="description" required></dd>
41+
</dl>
42+
<dl>
43+
<dt>Calories:</dt>
44+
<dd><input type="number" value="${meal.calories}" name="calories" required></dd>
45+
</dl>
46+
<button type="submit">Save</button>
47+
<button onclick="window.history.back()" type="button">Cancel</button>
48+
</form>
49+
</section>
50+
</body>
51+
</html>

0 commit comments

Comments
 (0)