From 96e8b19f41e9d250d1fbdbc67ce927771eec8de4 Mon Sep 17 00:00:00 2001 From: CodeSteak Date: Thu, 5 Mar 2020 20:34:59 +0100 Subject: [PATCH] Implement message for info --- .../java/org/hso/ecommerce/app/Config.java | 2 ++ .../components/InfoDemoInterceptor.java | 28 +++++++++++++++++++ .../org/hso/ecommerce/contoller/Login.java | 1 + .../src/main/resources/static/css/ecom.css | 6 ++++ .../resources/templates/fragments/header.html | 16 ++++++++++- 5 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 prototype/src/main/java/org/hso/ecommerce/components/InfoDemoInterceptor.java diff --git a/prototype/src/main/java/org/hso/ecommerce/app/Config.java b/prototype/src/main/java/org/hso/ecommerce/app/Config.java index 22006ab..70d46c0 100644 --- a/prototype/src/main/java/org/hso/ecommerce/app/Config.java +++ b/prototype/src/main/java/org/hso/ecommerce/app/Config.java @@ -1,5 +1,6 @@ package org.hso.ecommerce.app; +import org.hso.ecommerce.components.InfoDemoInterceptor; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @@ -15,5 +16,6 @@ public class Config implements WebMvcConfigurer { public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(new LoginIntercepter()); registry.addInterceptor(new ErrorDemoInterceptor()); + registry.addInterceptor(new InfoDemoInterceptor()); } } diff --git a/prototype/src/main/java/org/hso/ecommerce/components/InfoDemoInterceptor.java b/prototype/src/main/java/org/hso/ecommerce/components/InfoDemoInterceptor.java new file mode 100644 index 0000000..ff76464 --- /dev/null +++ b/prototype/src/main/java/org/hso/ecommerce/components/InfoDemoInterceptor.java @@ -0,0 +1,28 @@ +package org.hso.ecommerce.components; + +import org.springframework.stereotype.Component; +import org.springframework.web.servlet.HandlerInterceptor; +import org.springframework.web.servlet.ModelAndView; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +@Component +public class InfoDemoInterceptor implements HandlerInterceptor { + @Override + public boolean preHandle( + HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { + + request.setAttribute("info", request.getParameter("info")); + return true; + } + @Override + public void postHandle( + HttpServletRequest request, HttpServletResponse response, Object handler, + ModelAndView modelAndView) throws Exception { + } + + @Override + public void afterCompletion(HttpServletRequest request, HttpServletResponse response, + Object handler, Exception exception) throws Exception {} +} diff --git a/prototype/src/main/java/org/hso/ecommerce/contoller/Login.java b/prototype/src/main/java/org/hso/ecommerce/contoller/Login.java index e545de8..00f08df 100644 --- a/prototype/src/main/java/org/hso/ecommerce/contoller/Login.java +++ b/prototype/src/main/java/org/hso/ecommerce/contoller/Login.java @@ -3,6 +3,7 @@ package org.hso.ecommerce.contoller; import org.hso.ecommerce.db.CustomerRepository; import org.hso.ecommerce.entities.Customer; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; import javax.servlet.http.Cookie; import java.util.List; diff --git a/prototype/src/main/resources/static/css/ecom.css b/prototype/src/main/resources/static/css/ecom.css index 693b2f7..1d8f125 100644 --- a/prototype/src/main/resources/static/css/ecom.css +++ b/prototype/src/main/resources/static/css/ecom.css @@ -765,6 +765,12 @@ input[type="number"]:focus { font-size: var(--u0); } +.info { + background-color: var(--c-secondary); + text-align: center; + font-size: var(--u0); +} + /* * Impov */ diff --git a/prototype/src/main/resources/templates/fragments/header.html b/prototype/src/main/resources/templates/fragments/header.html index 133fb74..84e8d56 100644 --- a/prototype/src/main/resources/templates/fragments/header.html +++ b/prototype/src/main/resources/templates/fragments/header.html @@ -40,7 +40,21 @@ X - + +
+
+
+ Info +
+
+ + X +
+