From 4b8ce97ba87f27195ebfe0155fcfa1a59880e8f3 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sun, 6 Sep 2015 11:13:36 +0200 Subject: [PATCH] =?utf8?q?Brought=20back=20the=20mini=20basket=20"tag"=20t?= =?utf8?q?o=20live=20+=20added=20post-construct=20init()=20method.=20Signe?= =?utf8?q?d-off-by:Roland=20H=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- lib/jcoreee.jar | Bin 20440 -> 20445 bytes nbproject/project.properties | 21 +++++-- .../beans/basket/PizzaBasketWebBean.java | 40 +++++++++++++ .../basket/PizzaServiceBasketWebBean.java | 54 ++++++++++++++++++ .../beans/controller/PizzaServiceWebBean.java | 42 ++++++-------- .../beans/controller/PizzaWebBean.java | 35 ++++++------ .../customer/PizzaServiceCustomerWebBean.java | 8 +++ .../beans/{enums => data}/DataWebBean.java | 2 +- .../PizzaServiceDataWebBean.java | 2 +- web/WEB-INF/templates/basket/mini_basket.tpl | 24 ++++++++ .../templates/basket/mini_basket_empty.tpl | 10 ++++ web/WEB-INF/templates/guest/guest_base.tpl | 12 ++-- 12 files changed, 197 insertions(+), 53 deletions(-) create mode 100644 src/java/org/mxchange/pizzaapplication/beans/basket/PizzaBasketWebBean.java create mode 100644 src/java/org/mxchange/pizzaapplication/beans/basket/PizzaServiceBasketWebBean.java rename src/java/org/mxchange/pizzaapplication/beans/{enums => data}/DataWebBean.java (96%) rename src/java/org/mxchange/pizzaapplication/beans/{enums => data}/PizzaServiceDataWebBean.java (97%) create mode 100644 web/WEB-INF/templates/basket/mini_basket.tpl create mode 100644 web/WEB-INF/templates/basket/mini_basket_empty.tpl diff --git a/lib/jcoreee.jar b/lib/jcoreee.jar index 6b049a2cc5958ef61960a46098335ae642c838c6..e94d33f4b7bc5b18217ee5a4cb36a81e3c77a032 100644 GIT binary patch delta 741 zcmY+A&r4KM6vyv<&v`$FxryOm<=|AK;2>jSAM&oKb9x)%Dy{JYeS4#2;I&8yS34B7OV3OR?#MN;pjLa&Loq6=GqY30 z8Pj_&H4C%~4wOb}z+a^s`}C+9#b7Z!8p2?=x=zC2DB8hr#Nz75FY}BLt{#8Hb%?ix z;7MaG6mpU`pLoE~|GTwVDIC&R7+t zLe@(^qW+j`@YQKTV_=g3VJ&(-vr~6bV@@g~TMm>C#A*l2Pfr`%*eAMwrItg4JmESa0Pv#B#NGETnFp~C1jnT68^tk;>-oDs~Z zzNB%-4sBk_)bfdPc|fEWgrG#XBx;A0EceZfbXDVu9@ zqo>;B_d^!Zp4c3Lw+Eay?!?. + */ +package org.mxchange.pizzaapplication.beans.basket; + +import org.mxchange.jcoreee.beans.FrameworkBean; + +/** + * An interface for a basket + * + * @author Roland Haeder + */ +public interface PizzaBasketWebBean extends FrameworkBean { + /** + * Checks whether the basket is empty + * + * @return Whether the basket is empty + */ + public boolean isEmpty (); + + /** + * Checks whether the basket has items in it. This method is wrapper to isEmpty() + * + * @return Whether the basket is empty + */ + public boolean hasItems (); +} diff --git a/src/java/org/mxchange/pizzaapplication/beans/basket/PizzaServiceBasketWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/basket/PizzaServiceBasketWebBean.java new file mode 100644 index 00000000..0b185c00 --- /dev/null +++ b/src/java/org/mxchange/pizzaapplication/beans/basket/PizzaServiceBasketWebBean.java @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2015 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.pizzaapplication.beans.basket; + +import javax.annotation.PostConstruct; +import javax.enterprise.context.SessionScoped; +import javax.inject.Named; +import org.mxchange.jcoreee.beans.BaseFrameworkBean; + +/** + * A bean for the basket + * + * @author Roland Haeder + */ +@Named("basket") +@SessionScoped +public class PizzaServiceBasketWebBean extends BaseFrameworkBean implements PizzaBasketWebBean { + /** + * Serial number + */ + private static final long serialVersionUID = 5476347320198L; + + @Override + public boolean isEmpty () { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public boolean hasItems () { + // Call above and invert it + return (!this.isEmpty()); + } + + @Override + @PostConstruct + public void init () throws RuntimeException { + // Call super init first + super.localInit(); + } +} diff --git a/src/java/org/mxchange/pizzaapplication/beans/controller/PizzaServiceWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/controller/PizzaServiceWebBean.java index 06465f62..41cbd641 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/controller/PizzaServiceWebBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/controller/PizzaServiceWebBean.java @@ -17,7 +17,6 @@ package org.mxchange.pizzaapplication.beans.controller; import java.io.IOException; -import java.rmi.RemoteException; import java.sql.SQLException; import java.util.Deque; import java.util.Iterator; @@ -79,91 +78,88 @@ public class PizzaServiceWebBean extends BaseFrameworkBean implements PizzaWebBe @Override @PostConstruct - public void init () throws FacesException { - // Trace message - this.getLogger().trace("CALLED!"); //NOI18N - - // Super call - super.init(); + public void init () throws RuntimeException { + // Call super init first + super.localInit(); } @Override - public Iterator getAvailableProductsIterator () throws RemoteException { + public Iterator getAvailableProductsIterator () throws FacesException { try { return this.remote.getAvailableProductsIterator(); } catch (final IOException | SQLException ex) { // Continue to throw - throw new RemoteException("getAvailableProductsIterator() failed", ex); + throw new FacesException(ex); } } @Override - public Iterator getAllProductsIterator () throws RemoteException { + public Iterator getAllProductsIterator () throws FacesException { try { return this.remote.getAllProductsIterator(); } catch (final IOException | SQLException ex) { // Continue to throw - throw new RemoteException("getAllProductsIterator() failed.", ex); + throw new FacesException(ex); } } @Override - public Deque getAvailableProducts () throws RemoteException { + public Deque getAvailableProducts () throws FacesException { try { return this.remote.getAvailableProducts(); } catch (final IOException | SQLException ex) { // Continue to throw - throw new RemoteException("getAvailableProducts() failed.", ex); + throw new FacesException(ex); } } @Override - public Deque getAllProducts () throws RemoteException { + public Deque getAllProducts () throws FacesException { try { return this.remote.getAllProducts(); } catch (final IOException | SQLException ex) { // Continue to throw - throw new RemoteException("getAllProducts() failed", ex); + throw new FacesException(ex); } } @Override - public Iterator getAllCategoriesIterator () throws RemoteException { + public Iterator getAllCategoriesIterator () throws FacesException { try { return this.remote.getAllCategoriesIterator(); } catch (final IOException | SQLException ex) { // Continue to throw - throw new RemoteException("getAllCategoriesIterator() failed.", ex); + throw new FacesException(ex); } } @Override - public Deque getAllCategories () throws RemoteException { + public Deque getAllCategories () throws FacesException { try { return this.remote.getAllCategories(); } catch (final IOException | SQLException ex) { // Continue to throw - throw new RemoteException("getAllCategories() failed.", ex); + throw new FacesException(ex); } } @Override - public void doAdminAddCategory (final Category category) throws RemoteException { + public void doAdminAddCategory (final Category category) throws FacesException { try { this.remote.doAdminAddCategory(category); } catch (final IOException | SQLException | CategoryTitleAlreadyUsedException ex) { // Continue to throw - throw new RemoteException("doAdminAddCategory() failed.", ex); + throw new FacesException(ex); } } @Override - public void doAdminAddProduct (final Product product) throws RemoteException { + public void doAdminAddProduct (final Product product) throws FacesException { try { this.remote.doAdminAddProduct(product); } catch (final IOException | SQLException | ProductTitleAlreadyUsedException ex) { // Continue to throw - throw new RemoteException("doAdminAddProduct() failed.", ex); + throw new FacesException(ex); } } } diff --git a/src/java/org/mxchange/pizzaapplication/beans/controller/PizzaWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/controller/PizzaWebBean.java index 02c3f5ee..fb92bcc9 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/controller/PizzaWebBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/controller/PizzaWebBean.java @@ -16,14 +16,15 @@ */ package org.mxchange.pizzaapplication.beans.controller; -import java.rmi.RemoteException; import java.util.Deque; import java.util.Iterator; +import javax.faces.view.facelets.FaceletException; import org.mxchange.jcoreee.beans.FrameworkBean; import org.mxchange.jshopcore.model.category.Category; import org.mxchange.jshopcore.model.product.Product; /** + * An interface for the shop * * @author Roland Haeder */ @@ -33,63 +34,63 @@ public interface PizzaWebBean extends FrameworkBean { * Some "getter" for an iterator of only available products * * @return Only available products - * @throws java.rmi.RemoteException If anything went wrong + * @throws javax.faces.view.facelets.FaceletException If anything went wrong */ - public Iterator getAvailableProductsIterator () throws RemoteException; + public Iterator getAvailableProductsIterator () throws FaceletException; /** * Some "getter" for an iterator of all products * * @return All products - * @throws java.rmi.RemoteException If anything went wrong + * @throws javax.faces.view.facelets.FaceletException If anything went wrong */ - public Iterator getAllProductsIterator () throws RemoteException; + public Iterator getAllProductsIterator () throws FaceletException; /** * Some "getter" for an iterator of all categories * * @return All categories - * @throws java.rmi.RemoteException If anything went wrong + * @throws javax.faces.view.facelets.FaceletException If anything went wrong */ - public Iterator getAllCategoriesIterator () throws RemoteException; + public Iterator getAllCategoriesIterator () throws FaceletException; /** * Some "getter" for a linked list of only available products * * @return Only available products - * @throws java.rmi.RemoteException If anything went wrong + * @throws javax.faces.view.facelets.FaceletException If anything went wrong */ - public Deque getAvailableProducts () throws RemoteException; + public Deque getAvailableProducts () throws FaceletException; /** * Some "getter" for a linked list of all products * * @return All products - * @throws java.rmi.RemoteException If anything went wrong + * @throws javax.faces.view.facelets.FaceletException If anything went wrong */ - public Deque getAllProducts () throws RemoteException; + public Deque getAllProducts () throws FaceletException; /** * Some "getter" for a linked list of all categories * * @return All categories - * @throws java.rmi.RemoteException If anything went wrong + * @throws javax.faces.view.facelets.FaceletException If anything went wrong */ - public Deque getAllCategories () throws RemoteException; + public Deque getAllCategories () throws FaceletException; /** * Adds given category data from request to database * * @param category Category instance - * @throws java.rmi.RemoteException If something unexpected happened + * @throws javax.faces.view.facelets.FaceletException If something unexpected happened */ - public void doAdminAddCategory (final Category category) throws RemoteException; + public void doAdminAddCategory (final Category category) throws FaceletException; /** * Adds given product data from request to database * * @param product Product instance - * @throws java.rmi.RemoteException If something unexpected happened + * @throws javax.faces.view.facelets.FaceletException If something unexpected happened */ - public void doAdminAddProduct (final Product product) throws RemoteException; + public void doAdminAddProduct (final Product product) throws FaceletException; } diff --git a/src/java/org/mxchange/pizzaapplication/beans/customer/PizzaServiceCustomerWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/customer/PizzaServiceCustomerWebBean.java index 5154463b..efafe691 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/customer/PizzaServiceCustomerWebBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/customer/PizzaServiceCustomerWebBean.java @@ -16,6 +16,7 @@ */ package org.mxchange.pizzaapplication.beans.customer; +import javax.annotation.PostConstruct; import javax.ejb.EJB; import javax.enterprise.context.SessionScoped; import javax.inject.Named; @@ -46,4 +47,11 @@ public class PizzaServiceCustomerWebBean extends BaseFrameworkBean implements Cu */ public PizzaServiceCustomerWebBean () { } + + @Override + @PostConstruct + public void init () throws RuntimeException { + // Call super init first + super.localInit(); + } } diff --git a/src/java/org/mxchange/pizzaapplication/beans/enums/DataWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/data/DataWebBean.java similarity index 96% rename from src/java/org/mxchange/pizzaapplication/beans/enums/DataWebBean.java rename to src/java/org/mxchange/pizzaapplication/beans/data/DataWebBean.java index 076b02b2..6393c84c 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/enums/DataWebBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/data/DataWebBean.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.mxchange.pizzaapplication.beans.enums; +package org.mxchange.pizzaapplication.beans.data; import java.util.List; import org.mxchange.jcore.model.contact.gender.Gender; diff --git a/src/java/org/mxchange/pizzaapplication/beans/enums/PizzaServiceDataWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/data/PizzaServiceDataWebBean.java similarity index 97% rename from src/java/org/mxchange/pizzaapplication/beans/enums/PizzaServiceDataWebBean.java rename to src/java/org/mxchange/pizzaapplication/beans/data/PizzaServiceDataWebBean.java index 06b81617..b8c95af8 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/enums/PizzaServiceDataWebBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/data/PizzaServiceDataWebBean.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.mxchange.pizzaapplication.beans.enums; +package org.mxchange.pizzaapplication.beans.data; import java.text.MessageFormat; import java.util.List; diff --git a/web/WEB-INF/templates/basket/mini_basket.tpl b/web/WEB-INF/templates/basket/mini_basket.tpl new file mode 100644 index 00000000..050ca2ce --- /dev/null +++ b/web/WEB-INF/templates/basket/mini_basket.tpl @@ -0,0 +1,24 @@ + + +
+
+ #{msg.mini_basket.header} +
+ +
+ #{msg.mini_basket.last_item} +
+ +
+ #{msg.mini_basket.additional_items} +
+ + +
+
diff --git a/web/WEB-INF/templates/basket/mini_basket_empty.tpl b/web/WEB-INF/templates/basket/mini_basket_empty.tpl new file mode 100644 index 00000000..a4339b7d --- /dev/null +++ b/web/WEB-INF/templates/basket/mini_basket_empty.tpl @@ -0,0 +1,10 @@ + + +
+ #{MiniBasketTag.basket_is_empty} +
+
diff --git a/web/WEB-INF/templates/guest/guest_base.tpl b/web/WEB-INF/templates/guest/guest_base.tpl index 5d8856b0..58f5a1e2 100644 --- a/web/WEB-INF/templates/guest/guest_base.tpl +++ b/web/WEB-INF/templates/guest/guest_base.tpl @@ -1,13 +1,15 @@ + + + + + + -- 2.39.5