removed isbn field from addbook page
set default values for year and price in addbook form
This commit is contained in:
parent
2cf2646f76
commit
d3dff89b4e
@ -23,13 +23,13 @@ public class AddBook extends HttpServlet {
|
||||
ArrayList<Book> books = db.getBooks();
|
||||
|
||||
out.println("<form class=\"m-container\" action=\"booklist\" method=post>");
|
||||
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("</form>");
|
||||
|
||||
|
@ -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");
|
||||
|
@ -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(" <div class=\"m-row\">");
|
||||
out.println(" <div class=\"m-col-l-2 m-push-l-5\">");
|
||||
out.println(label);
|
||||
out.println("<input type=\"text\" name=\"" + name + "\">");
|
||||
out.println("<input type=\"text\" name=\"" + name + "\" value=\"" + value + "\">");
|
||||
out.println("</div>");
|
||||
out.println("</div>");
|
||||
}
|
||||
@ -39,13 +43,23 @@ public class Utillity {
|
||||
}
|
||||
|
||||
static public void addTypeButton(PrintWriter out, String label, String type){
|
||||
/*
|
||||
out.println(" <div class=\"m-row\">");
|
||||
out.println(" <div class=\"m-col-l-4 m-push-l-4\">");
|
||||
//out.println(" <div class=\"m-button m-success\">");
|
||||
out.println("<input type=\"" + type + "\" value=\"" + label + "\">");
|
||||
//out.println("<input type=" + type + " value=" + label + ">");
|
||||
//out.println(" </div>");
|
||||
out.println(" <div class=\"m-button m-success\">");
|
||||
out.println("<a href=\"" + "" + "\">");
|
||||
out.println(label);
|
||||
out.println("<input class=\"m-button m-success\" type=\"" + type + "\" value=\"" + label + "\">");
|
||||
out.println("</a>");
|
||||
out.println(" </div>");
|
||||
out.println("</div>");
|
||||
out.println("</div>");
|
||||
*/
|
||||
|
||||
out.println(" <div class=\"m-row\">");
|
||||
out.println(" <div class=\"m-col-l-4 m-push-l-5\">");
|
||||
out.println(" <input type=\"" + type + "\" value=\"" + label + "\">");
|
||||
out.println(" </div>");
|
||||
out.println("</div>");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user