diff --git a/src/main/java/de/hsel/itech/servlet/AddBook.java b/src/main/java/de/hsel/itech/servlet/AddBook.java index cabd6b3..77477a3 100644 --- a/src/main/java/de/hsel/itech/servlet/AddBook.java +++ b/src/main/java/de/hsel/itech/servlet/AddBook.java @@ -23,13 +23,13 @@ public class AddBook extends HttpServlet { ArrayList books = db.getBooks(); out.println("
"); - Utillity.addInput(out,"ISBN", "isbn"); Utillity.addInput(out,"Titel", "title"); Utillity.addInput(out,"Author", "author"); - Utillity.addInput(out,"Preis", "price"); - Utillity.addInput(out,"Jahr", "year"); + Utillity.addInput(out,"Preis", "price", "0"); + Utillity.addInput(out,"Jahr", "year", "2019"); Utillity.addInput(out,"Beschreibung", "description"); Utillity.addInput(out,"Verlag", "publisher"); + Utillity.addInput(out,"Bild", "image", "DxAzOKSiPoE"); Utillity.addTypeButton(out, "Hinzufügen", "submit"); out.println("
"); diff --git a/src/main/java/de/hsel/itech/servlet/BookList.java b/src/main/java/de/hsel/itech/servlet/BookList.java index c2622b7..99a29ec 100644 --- a/src/main/java/de/hsel/itech/servlet/BookList.java +++ b/src/main/java/de/hsel/itech/servlet/BookList.java @@ -13,6 +13,7 @@ import java.io.PrintWriter; import java.time.Year; import java.util.ArrayList; import java.util.Enumeration; +import java.util.Random; public class BookList extends HttpServlet { @@ -33,13 +34,11 @@ public class BookList extends HttpServlet { String param = req.getParameter("removeid"); if(param != null){ long isbn = Long.parseLong(param); - //TODO remove book from Database db.removeBook(isbn); + resp.sendRedirect("booklist"); } - param = req.getParameter("isbn"); - if(param != null){ - long isbn = Long.parseLong(param); + if(req.getParameter("title") != null){ String title = req.getParameter("title"); String author = req.getParameter("author"); int price = Integer.parseInt(req.getParameter("price")); @@ -47,15 +46,15 @@ public class BookList extends HttpServlet { String category = req.getParameter("category"); String description = req.getParameter("description"); String publisher = req.getParameter("publisher"); + String image = req.getParameter("image"); Book book = new Book( - 0, + new Random().nextInt(), new Author(0,author), new Publisher(0,publisher), new Category(0,category, "DxAzOKSiPoE"), - title, Year.of(year),price,description, "DxAzOKSiPoE" + title, Year.of(year),price,description, image ); - //TODO add book db.addBook(book); resp.sendRedirect("booklist"); diff --git a/src/main/java/de/hsel/itech/servlet/Utillity.java b/src/main/java/de/hsel/itech/servlet/Utillity.java index 74b998a..dddceac 100644 --- a/src/main/java/de/hsel/itech/servlet/Utillity.java +++ b/src/main/java/de/hsel/itech/servlet/Utillity.java @@ -18,10 +18,14 @@ public class Utillity { } static public void addInput(PrintWriter out, String label, String name){ + addInput(out,label,name,""); + } + + static public void addInput(PrintWriter out, String label, String name, String value){ out.println("
"); out.println("
"); out.println(label); - out.println(""); + out.println(""); out.println("
"); out.println("
"); } @@ -39,13 +43,23 @@ public class Utillity { } static public void addTypeButton(PrintWriter out, String label, String type){ + /* out.println("
"); out.println("
"); - //out.println("
"); - out.println(""); - //out.println(""); - //out.println("
"); + out.println(" "); out.println("
"); out.println("
"); + */ + + out.println("
"); + out.println("
"); + out.println(" "); + out.println("
"); + out.println("
"); } }