From 79a20f54d30dd8d927b5947d4aa6b3fdd96acdf1 Mon Sep 17 00:00:00 2001 From: CodeSteak Date: Thu, 6 Feb 2020 19:44:51 +0100 Subject: [PATCH] impl error in header --- .../java/org/hso/ecommerce/app/Config.java | 4 +- .../components/ErrorDemoInterceptor.java | 31 ++++++++++ .../src/main/resources/static/css/ecom.css | 6 ++ .../resources/templates/fragments/header.html | 61 ++++++++++++------- 4 files changed, 80 insertions(+), 22 deletions(-) create mode 100644 prototype/src/main/java/org/hso/ecommerce/components/ErrorDemoInterceptor.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 be6dfa9..22006ab 100644 --- a/prototype/src/main/java/org/hso/ecommerce/app/Config.java +++ b/prototype/src/main/java/org/hso/ecommerce/app/Config.java @@ -6,6 +6,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import org.hso.ecommerce.components.LoginIntercepter; +import org.hso.ecommerce.components.ErrorDemoInterceptor; @Configuration public class Config implements WebMvcConfigurer { @@ -13,5 +14,6 @@ public class Config implements WebMvcConfigurer { @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(new LoginIntercepter()); + registry.addInterceptor(new ErrorDemoInterceptor()); } -} \ No newline at end of file +} diff --git a/prototype/src/main/java/org/hso/ecommerce/components/ErrorDemoInterceptor.java b/prototype/src/main/java/org/hso/ecommerce/components/ErrorDemoInterceptor.java new file mode 100644 index 0000000..d25f4c4 --- /dev/null +++ b/prototype/src/main/java/org/hso/ecommerce/components/ErrorDemoInterceptor.java @@ -0,0 +1,31 @@ +package org.hso.ecommerce.components; + +import org.springframework.boot.web.servlet.server.Session; +import org.springframework.stereotype.Component; +import org.springframework.ui.Model; +import org.springframework.web.servlet.HandlerInterceptor; +import org.springframework.web.servlet.ModelAndView; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +@Component +public class ErrorDemoInterceptor implements HandlerInterceptor { + @Override + public boolean preHandle( + HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { + + request.setAttribute("error", request.getParameter("error")); + 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/resources/static/css/ecom.css b/prototype/src/main/resources/static/css/ecom.css index 59106bb..693b2f7 100644 --- a/prototype/src/main/resources/static/css/ecom.css +++ b/prototype/src/main/resources/static/css/ecom.css @@ -759,6 +759,12 @@ input[type="number"]:focus { padding: var(--u0); } +.error { + background-color: var(--c-error); + 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 d3d3053..133fb74 100644 --- a/prototype/src/main/resources/templates/fragments/header.html +++ b/prototype/src/main/resources/templates/fragments/header.html @@ -1,29 +1,48 @@ + - - eCommerce + + eCommerce + - +