From: Roland Haeder Date: Sun, 6 Sep 2015 09:13:36 +0000 (+0200) Subject: Brought back the mini basket "tag" to live + added post-construct init() method. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=4b8ce97ba87f27195ebfe0155fcfa1a59880e8f3;p=pizzaservice-war.git Brought back the mini basket "tag" to live + added post-construct init() method. Signed-off-by:Roland Häder --- diff --git a/lib/jcoreee.jar b/lib/jcoreee.jar index 6b049a2c..e94d33f4 100644 Binary files a/lib/jcoreee.jar and b/lib/jcoreee.jar differ diff --git a/nbproject/project.properties b/nbproject/project.properties index c8f807dd..dff1975c 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -3,6 +3,14 @@ annotation.processing.enabled.in.editor=true annotation.processing.processors.list= annotation.processing.run.all.processors=true annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +auxiliary.org-netbeans-modules-css-prep.less_2e_compiler_2e_options= +auxiliary.org-netbeans-modules-css-prep.less_2e_enabled=false +auxiliary.org-netbeans-modules-css-prep.less_2e_mappings=/less:/css +auxiliary.org-netbeans-modules-css-prep.sass_2e_compiler_2e_options= +auxiliary.org-netbeans-modules-css-prep.sass_2e_enabled=false +auxiliary.org-netbeans-modules-css-prep.sass_2e_mappings=/scss:/css +auxiliary.org-netbeans-modules-projectapi.jsf_2e_language=Facelets +auxiliary.org-netbeans-modules-web-clientproject-api.js_2e_libs_2e_folder=js/libs build.classes.dir=${build.web.dir}/WEB-INF/classes build.classes.excludes=**/*.java,**/*.form build.dir=build @@ -62,9 +70,9 @@ javac.classpath=\ ${file.reference.log4j-core-2.3.jar}:\ ${file.reference.log4j-web-2.3.jar} # Space-separated list of extra javac options -javac.compilerargs= +javac.compilerargs=-Xlint:unchecked -Xlint:deprecation javac.debug=true -javac.deprecation=false +javac.deprecation=true javac.processorpath=\ ${javac.classpath} javac.source=1.7 @@ -75,20 +83,21 @@ javac.test.classpath=\ javac.test.processorpath=\ ${javac.test.classpath} javadoc.additionalparam= -javadoc.author=false +javadoc.author=true javadoc.encoding=${source.encoding} javadoc.noindex=false javadoc.nonavbar=false javadoc.notree=false javadoc.preview=true -javadoc.private=false +javadoc.private=true javadoc.splitindex=true javadoc.use=true -javadoc.version=false -javadoc.windowtitle= +javadoc.version=true +javadoc.windowtitle=Pizza-Service Application lib.dir=${web.docbase.dir}/WEB-INF/lib persistence.xml.dir=${conf.dir} platform.active=default_platform +project.license=gpl30 project.PizzaService-lib=../pizzaservice-lib reference.PizzaService-lib.jar=${project.PizzaService-lib}/dist/PizzaService-lib.jar resource.dir=setup diff --git a/src/java/org/mxchange/pizzaapplication/beans/basket/PizzaBasketWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/basket/PizzaBasketWebBean.java new file mode 100644 index 00000000..55bd4087 --- /dev/null +++ b/src/java/org/mxchange/pizzaapplication/beans/basket/PizzaBasketWebBean.java @@ -0,0 +1,40 @@ +/* + * 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 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/data/DataWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/data/DataWebBean.java new file mode 100644 index 00000000..6393c84c --- /dev/null +++ b/src/java/org/mxchange/pizzaapplication/beans/data/DataWebBean.java @@ -0,0 +1,43 @@ +/* + * 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.data; + +import java.util.List; +import org.mxchange.jcore.model.contact.gender.Gender; +import org.mxchange.jcoreee.beans.FrameworkBean; + +/** + * An interface for data beans + * + * @author Roland Haeder + */ +public interface DataWebBean extends FrameworkBean { + + /** + * Getter for all genders as array + * + * @return All genders as array + */ + public Gender[] allGenders (); + + /** + * Getter for only selectable genders as array, UNKNOWN is not selectable + * + * @return All genders as array + */ + public List selectableGenders (); +} diff --git a/src/java/org/mxchange/pizzaapplication/beans/data/PizzaServiceDataWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/data/PizzaServiceDataWebBean.java new file mode 100644 index 00000000..b8c95af8 --- /dev/null +++ b/src/java/org/mxchange/pizzaapplication/beans/data/PizzaServiceDataWebBean.java @@ -0,0 +1,92 @@ +/* + * 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.data; + +import java.text.MessageFormat; +import java.util.List; +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Named; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import org.mxchange.jcore.model.contact.gender.Gender; +import org.mxchange.jcoreee.beans.BaseFrameworkBean; +import org.mxchange.jshopeelib.beans.remote.data.ShopDataBeanRemote; + +/** + * A customer bean which hides the customer instance + * + * @author Roland Haeder + */ +@Named ("data") +@ApplicationScoped +public class PizzaServiceDataWebBean extends BaseFrameworkBean implements DataWebBean { + + /** + * Serial number + */ + private static final long serialVersionUID = 835482364189L; + + /** + * Remote bean + */ + private final ShopDataBeanRemote remote; + + /** + * Default constructor + * + * @throws javax.naming.NamingException If something happens? + */ + public PizzaServiceDataWebBean () throws NamingException { + // Get initial context + InitialContext context = new InitialContext(); + + // Try to lookup bean + this.remote = (ShopDataBeanRemote) context.lookup("ejb/stateless-data"); + } + + @Override + public Gender[] allGenders () { + // Trace message + this.getLogger().trace("CALLED!"); + + // Return it + return this.getRemote().allGenders(); + } + + @Override + public List selectableGenders () { + // Trace message + this.getLogger().trace("CALLED!"); //NOI18N + + // Init array + // TODO Call EJB here? + List genders = this.getRemote().selectableGenders(); + + // Trace message + this.getLogger().trace(MessageFormat.format("genders={0} - EXIT!", genders)); //NOI18N + + // Return it + return genders; + } + + /** + * @return the remote + */ + private ShopDataBeanRemote getRemote () { + return this.remote; + } +} diff --git a/src/java/org/mxchange/pizzaapplication/beans/enums/DataWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/enums/DataWebBean.java deleted file mode 100644 index 076b02b2..00000000 --- a/src/java/org/mxchange/pizzaapplication/beans/enums/DataWebBean.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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.enums; - -import java.util.List; -import org.mxchange.jcore.model.contact.gender.Gender; -import org.mxchange.jcoreee.beans.FrameworkBean; - -/** - * An interface for data beans - * - * @author Roland Haeder - */ -public interface DataWebBean extends FrameworkBean { - - /** - * Getter for all genders as array - * - * @return All genders as array - */ - public Gender[] allGenders (); - - /** - * Getter for only selectable genders as array, UNKNOWN is not selectable - * - * @return All genders as array - */ - public List selectableGenders (); -} diff --git a/src/java/org/mxchange/pizzaapplication/beans/enums/PizzaServiceDataWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/enums/PizzaServiceDataWebBean.java deleted file mode 100644 index 06b81617..00000000 --- a/src/java/org/mxchange/pizzaapplication/beans/enums/PizzaServiceDataWebBean.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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.enums; - -import java.text.MessageFormat; -import java.util.List; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Named; -import javax.naming.InitialContext; -import javax.naming.NamingException; -import org.mxchange.jcore.model.contact.gender.Gender; -import org.mxchange.jcoreee.beans.BaseFrameworkBean; -import org.mxchange.jshopeelib.beans.remote.data.ShopDataBeanRemote; - -/** - * A customer bean which hides the customer instance - * - * @author Roland Haeder - */ -@Named ("data") -@ApplicationScoped -public class PizzaServiceDataWebBean extends BaseFrameworkBean implements DataWebBean { - - /** - * Serial number - */ - private static final long serialVersionUID = 835482364189L; - - /** - * Remote bean - */ - private final ShopDataBeanRemote remote; - - /** - * Default constructor - * - * @throws javax.naming.NamingException If something happens? - */ - public PizzaServiceDataWebBean () throws NamingException { - // Get initial context - InitialContext context = new InitialContext(); - - // Try to lookup bean - this.remote = (ShopDataBeanRemote) context.lookup("ejb/stateless-data"); - } - - @Override - public Gender[] allGenders () { - // Trace message - this.getLogger().trace("CALLED!"); - - // Return it - return this.getRemote().allGenders(); - } - - @Override - public List selectableGenders () { - // Trace message - this.getLogger().trace("CALLED!"); //NOI18N - - // Init array - // TODO Call EJB here? - List genders = this.getRemote().selectableGenders(); - - // Trace message - this.getLogger().trace(MessageFormat.format("genders={0} - EXIT!", genders)); //NOI18N - - // Return it - return genders; - } - - /** - * @return the remote - */ - private ShopDataBeanRemote getRemote () { - return this.remote; - } -} 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 @@ + + + + + +