Aufgabe 3: fertig
This commit is contained in:
parent
2ef4187b37
commit
410004c557
@ -153,7 +153,7 @@ public class Database {
|
||||
@Nullable
|
||||
public Category getCategory(long id) {
|
||||
Map.Entry<ResultSet, Connection> entry = getResultSetById(category, id);
|
||||
assert entry != null;
|
||||
if(entry != null) {
|
||||
ResultSet rs = entry.getKey();
|
||||
|
||||
try {
|
||||
@ -163,6 +163,8 @@ public class Database {
|
||||
}
|
||||
return getCategory(entry);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* get category by name.
|
||||
|
30
src/main/webapp/categories.jsp
Normal file
30
src/main/webapp/categories.jsp
Normal file
@ -0,0 +1,30 @@
|
||||
<%@ page import="de.hsel.itech.db.Database" %>
|
||||
<%@ page import="de.hsel.itech.db.pojo.Category" %>
|
||||
<%@ page import="java.nio.charset.StandardCharsets" %>
|
||||
<%@ page import="java.util.Objects" %>
|
||||
<%@ page contentType="text/html;charset=UTF-8" %>
|
||||
<%@include file="header.html"%>
|
||||
<%
|
||||
request.setCharacterEncoding(StandardCharsets.UTF_8.name());
|
||||
response.setCharacterEncoding(StandardCharsets.UTF_8.name());
|
||||
%>
|
||||
<div class="m-container">
|
||||
<h1 class="m-text-center">Kategorien</h1>
|
||||
<div class="m-row">
|
||||
<%
|
||||
for(Category category : Objects.requireNonNull(Database.getInstance().getCategories())) {
|
||||
%>
|
||||
<div class="m-col-t-4">
|
||||
<a href="category.jsp?id=<%= category.getId() %>">
|
||||
<figure class="m-figure">
|
||||
<img src="https://source.unsplash.com/<%= category.getImage()%>/900x900" alt="<%=category.getName()%>">
|
||||
<figcaption class="m-text-center"><%=category.getName()%></figcaption>
|
||||
</figure>
|
||||
</a>
|
||||
</div>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
</div>
|
||||
</div>
|
||||
<%@include file="footer.html"%>
|
60
src/main/webapp/category.jsp
Normal file
60
src/main/webapp/category.jsp
Normal file
@ -0,0 +1,60 @@
|
||||
<%@ page import="de.hsel.itech.db.Database" %>
|
||||
<%@ page import="de.hsel.itech.db.pojo.Book" %>
|
||||
<%@ page import="de.hsel.itech.db.pojo.Category" %>
|
||||
<%@ page import="java.util.Objects" %>
|
||||
<%@ page import="java.nio.charset.StandardCharsets" %>
|
||||
<%@ page contentType="text/html;charset=UTF-8" %>
|
||||
<%@include file="header.html" %>
|
||||
<%
|
||||
request.setCharacterEncoding(StandardCharsets.UTF_8.name());
|
||||
response.setCharacterEncoding(StandardCharsets.UTF_8.name());
|
||||
String idValue = request.getParameter("id");
|
||||
Category category;
|
||||
Database db = Database.getInstance();
|
||||
if (idValue == null) {
|
||||
%>
|
||||
<div class="m-container">
|
||||
<aside class="m-note m-error">
|
||||
<h1 class="m-text-center">Die Kategorie ist leer.</h1>
|
||||
</aside>
|
||||
</div>
|
||||
<%
|
||||
} else {
|
||||
long id = Long.valueOf(idValue);
|
||||
category = db.getCategory(id);
|
||||
if (category != null) {
|
||||
%>
|
||||
<div class="m-container">
|
||||
<h1 class="m-text-center"><%= category.getName() %>
|
||||
</h1>
|
||||
<div class="m-row">
|
||||
<%
|
||||
for (Book book : Objects.requireNonNull(db.getBooks(category))) {
|
||||
%>
|
||||
<div class="m-col-t-4">
|
||||
<figure class="m-figure">
|
||||
<img src="https://source.unsplash.com/<%= book.getImage()%>/900x900" alt="<%=book.getTitle()%>">
|
||||
<figcaption class="m-text-center"><%=book.getTitle()%>
|
||||
</figcaption>
|
||||
</figure>
|
||||
</div>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
</div>
|
||||
</div>
|
||||
<%
|
||||
} else {
|
||||
%>
|
||||
<div class="m-container">
|
||||
<aside class="m-note m-error">
|
||||
<h1 class="m-text-center">Kategorie existiert nicht.</h1>
|
||||
</aside>
|
||||
</div>
|
||||
<%
|
||||
}
|
||||
}
|
||||
%>
|
||||
|
||||
|
||||
<%@include file="footer.html" %>
|
81
src/main/webapp/footer.html
Normal file
81
src/main/webapp/footer.html
Normal file
@ -0,0 +1,81 @@
|
||||
<footer>
|
||||
<nav>
|
||||
<div class="m-container">
|
||||
<div class="m-row">
|
||||
<div class="m-col-s-3 m-col-t-6">
|
||||
<h3>Hilfe</h3>
|
||||
<ul>
|
||||
<li><a href="#">FAQ</a></li>
|
||||
<li><a href="#">Rückgabe</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="m-col-s-3 m-col-t-6">
|
||||
<h3>Zahlung</h3>
|
||||
<ul>
|
||||
<li><a href="#">Kreditkarten</a></li>
|
||||
<li><a href="#">Gutscheine</a></li>
|
||||
<li><a href="#">Bankeinzug</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="m-clearfix-t"></div>
|
||||
<div class="m-col-s-3 m-col-t-6">
|
||||
<h3>Amazon light</h3>
|
||||
<ul>
|
||||
<li><a href="#">Über</a></li>
|
||||
<li><a href="#">Kontakt</a></li>
|
||||
<li><a href="#">Presse</a></li>
|
||||
<li><a href="#">Jobs</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="m-col-s-3 m-col-t-6">
|
||||
<h3>Rechtliches</h3>
|
||||
<ul>
|
||||
<li><a href="https://joethei.xyz/imprint">Impressum</a></li>
|
||||
<li><a href="https://joethei.xyz/privacy">Datenschutz</a></li>
|
||||
<li><a href="https://joethei.xyz/disclaimer">Haftung</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="m-row">
|
||||
<div class="m-col-l-10 m-push-l-1">
|
||||
<p>Amazon light. Copyright © <a href="#">B1</a>,
|
||||
2019. All rights reserved.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
|
||||
</footer>
|
||||
|
||||
|
||||
<script type="text/javascript" src="//code.jquery.com/jquery-1.11.0.min.js"></script>
|
||||
<script type="text/javascript" src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
|
||||
<script type="text/javascript" src="//cdn.jsdelivr.net/npm/slick-carousel@1.8.1/slick/slick.min.js"></script>
|
||||
<script>
|
||||
function changeTheme() {
|
||||
|
||||
if(document.getElementById('myonoffswitch').checked) {
|
||||
swapStyleSheet("dark", "#22272e");
|
||||
}else {
|
||||
swapStyleSheet("light", "#cb4b16");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function swapStyleSheet(sheet, color) {
|
||||
document.getElementById("pagestyle").setAttribute("href", "css/m-" + sheet + ".css");
|
||||
document.getElementById("pagecolor").setAttribute("content", color);
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
$('.slider').slick({
|
||||
infinite: true,
|
||||
slidesToShow: 6,
|
||||
slidesToScroll: 3
|
||||
})
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
65
src/main/webapp/header.html
Normal file
65
src/main/webapp/header.html
Normal file
@ -0,0 +1,65 @@
|
||||
<!Doctype html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<title>Amazon light</title>
|
||||
|
||||
<link rel="stylesheet" href="css/m-light.css" id="pagestyle"/>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Libre+Baskerville:400,400i,700,700i%7CSource+Code+Pro:400,400i,600" />
|
||||
<meta name="theme-color" content="#cb4b16" id="pagecolor"/>
|
||||
|
||||
<link href="css/custom.css" rel="stylesheet">
|
||||
<link href="css/slick-theme.css" rel="stylesheet">
|
||||
<link rel="stylesheet" type="text/css" href="//cdn.jsdelivr.net/npm/slick-carousel@1.8.1/slick/slick.css"/>
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<header>
|
||||
<nav id="navigation">
|
||||
<div class="m-container">
|
||||
<div class="m-row">
|
||||
<a href="" id="m-navbar-brand" class="m-col-t-9 m-col-m-none m-left-m"></a>
|
||||
<a id="m-navbar-show" href="#navigation" title="Show navigation"
|
||||
class="m-col-t-3 m-hide-m m-text-right"></a>
|
||||
<a id="m-navbar-hide" href="#" title="Hide navigation" class="m-col-t-3 m-hide-m m-text-right"></a>
|
||||
<div id="m-navbar-collapse" class="m-col-t-12 m-show-m m-col-m-none m-right-m">
|
||||
<div class="m-row">
|
||||
<ol class="m-col-t-6 m-col-m-none">
|
||||
<li><a href="#">Katalog</a></li>
|
||||
<li><a href="#">(1) Warenkorb</a></li>
|
||||
</ol>
|
||||
<ol class="m-col-t-6 m-col-m-none" start="4">
|
||||
<li>
|
||||
<a href="#">Mein Account</a>
|
||||
<ol>
|
||||
<li><a href="#">Meine Bestellungen</a></li>
|
||||
<li><a href="#">Adressen & Konten</a></li>
|
||||
<li><a href="#">Abmelden</a></li>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
||||
<ol class="m-col-t-6 m-col-m-none" start="6">
|
||||
<li>
|
||||
<a href="#"><i class="fas fa-ellipsis-v"></i></a>
|
||||
<ol>
|
||||
<li>Dark Theme
|
||||
<div class="onoffswitch">
|
||||
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch" onchange="changeTheme()">
|
||||
<label class="onoffswitch-label" for="myonoffswitch">
|
||||
<span class="onoffswitch-inner"></span>
|
||||
<span class="onoffswitch-switch"></span>
|
||||
</label>
|
||||
</div>
|
||||
</li>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
Loading…
Reference in New Issue
Block a user