From 48214f593de93ae985cebc95efc6bfdf70d8c9b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90inh=20Qu=E1=BB=91c=20Ch=C6=B0=C6=A1ng?= Date: Wed, 6 Mar 2024 18:34:24 +0700 Subject: [PATCH] edit logic for update-product page --- .../management/product/UpdateProductServlet.java | 2 +- .../assets/js/management/product/update-product.js | 6 ++++-- .../view/jsp/management/customer/customer-detail.jsp | 10 +++++----- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/java/io/hardingadonis/saledock/controller/management/product/UpdateProductServlet.java b/src/main/java/io/hardingadonis/saledock/controller/management/product/UpdateProductServlet.java index b6b94d2..eddf69e 100644 --- a/src/main/java/io/hardingadonis/saledock/controller/management/product/UpdateProductServlet.java +++ b/src/main/java/io/hardingadonis/saledock/controller/management/product/UpdateProductServlet.java @@ -104,7 +104,7 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) Singleton.productDAO.save(product); - response.sendRedirect("./product"); + response.sendRedirect("./product-detail?id=" + idP); } } diff --git a/src/main/webapp/view/assets/js/management/product/update-product.js b/src/main/webapp/view/assets/js/management/product/update-product.js index 237bea0..202c177 100644 --- a/src/main/webapp/view/assets/js/management/product/update-product.js +++ b/src/main/webapp/view/assets/js/management/product/update-product.js @@ -3,6 +3,8 @@ $(document).ready(function () { e.preventDefault(); var formData = new FormData(this); + + var productId = formData.get('id'); $.ajax({ type: 'POST', @@ -20,11 +22,11 @@ $(document).ready(function () { if (result.dismiss === Swal.DismissReason.timer) { console.log('I was closed by the timer') } - window.location.href = 'product'; + window.location.href = 'product-detail?id=' + productId; }); setTimeout(function () { - window.location.href = 'product'; + window.location.href = 'product-detail?id=' + productId; }, 1500); }, error: function (response) { diff --git a/src/main/webapp/view/jsp/management/customer/customer-detail.jsp b/src/main/webapp/view/jsp/management/customer/customer-detail.jsp index 3b0615b..c0b9acf 100644 --- a/src/main/webapp/view/jsp/management/customer/customer-detail.jsp +++ b/src/main/webapp/view/jsp/management/customer/customer-detail.jsp @@ -62,11 +62,11 @@
- - - + + +