From: Roland Haeder Date: Thu, 10 Sep 2015 13:40:33 +0000 (+0200) Subject: Updated author (email address) + jars + implemented very basic basket X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=c6444e92ac84a9d4bca30110b0da11bf3ca7574a;p=pizzaservice-war.git Updated author (email address) + jars + implemented very basic basket Signed-off-by:Roland Häder --- diff --git a/lib/jcore-ee-logger.jar b/lib/jcore-ee-logger.jar index 5ebf6d07..c6521224 100644 Binary files a/lib/jcore-ee-logger.jar and b/lib/jcore-ee-logger.jar differ diff --git a/lib/jcoreee.jar b/lib/jcoreee.jar index 963ff769..935a2c95 100644 Binary files a/lib/jcoreee.jar and b/lib/jcoreee.jar differ diff --git a/lib/jshop-core.jar b/lib/jshop-core.jar index 8bd977ac..4b07e19e 100644 Binary files a/lib/jshop-core.jar and b/lib/jshop-core.jar differ diff --git a/lib/jshop-ee-lib.jar b/lib/jshop-ee-lib.jar index 004480c6..f0772448 100644 Binary files a/lib/jshop-ee-lib.jar and b/lib/jshop-ee-lib.jar differ diff --git a/src/java/org/mxchange/localization/bundle_de_DE.properties b/src/java/org/mxchange/localization/bundle_de_DE.properties index f13ba238..4d740b5e 100644 --- a/src/java/org/mxchange/localization/bundle_de_DE.properties +++ b/src/java/org/mxchange/localization/bundle_de_DE.properties @@ -21,3 +21,6 @@ MiniBasketTag.last_item=Zuletzt hinzugefügt: {0} MiniBasketTag.additional_items=Es befinden sich noch {0} weitere Produkte im Warenkorb. MiniBasketTag.to_basket=Zum Warenkorb MiniBasketTag.header=Warenkorb +Category.has_no_parent_category=Keine Elternkategorie +Generic_YES=Ja +Generic_NO=Nein diff --git a/src/java/org/mxchange/localization/bundle_en_US.properties b/src/java/org/mxchange/localization/bundle_en_US.properties index 1dc42122..99889ee9 100644 --- a/src/java/org/mxchange/localization/bundle_en_US.properties +++ b/src/java/org/mxchange/localization/bundle_en_US.properties @@ -21,3 +21,6 @@ MiniBasketTag.last_item=Last added item: {0} MiniBasketTag.additional_items=There are {0} items in the basket. MiniBasketTag.to_basket=To basket MiniBasketTag.header=Basket +Category.has_no_parent_category=No parent category +Generic_YES=Yes +Generic_NO=No diff --git a/src/java/org/mxchange/pizzaapplication/beans/basket/BasketWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/basket/BasketWebBean.java index ce782214..f2b30cb7 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/basket/BasketWebBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/basket/BasketWebBean.java @@ -24,15 +24,19 @@ import javax.inject.Named; import javax.naming.InitialContext; import javax.naming.NamingException; import org.mxchange.jcoreee.beans.BaseFrameworkBean; +import org.mxchange.jshopcore.model.basket.AddableBasketItem; +import org.mxchange.jshopcore.model.basket.Basket; import org.mxchange.jshopcore.model.basket.BasketSessionBeanRemote; +import org.mxchange.jshopcore.model.basket.ShopBasket; +import org.mxchange.jshopcore.model.item.BasketItem; import org.mxchange.jshopcore.model.product.Product; /** * A bean for the basket * - * @author Roland Haeder + * @author Roland Haeder */ -@Named("basket") +@Named ("basket") @SessionScoped public class BasketWebBean extends BaseFrameworkBean implements BasketWebController { @@ -42,14 +46,14 @@ public class BasketWebBean extends BaseFrameworkBean implements BasketWebControl private static final long serialVersionUID = 5_476_347_320_198L; /** - * Basket bean + * Basket bean */ private final BasketSessionBeanRemote basketBean; /** - * Current product instance + * Item basket ("cache") */ - private Product currentProduct; + private final Basket basket; /** * Default constructor @@ -62,6 +66,36 @@ public class BasketWebBean extends BaseFrameworkBean implements BasketWebControl // Try to lookup this.basketBean = (BasketSessionBeanRemote) context.lookup("ejb/stateless-basket"); //NOI18N + + // Init basket "cache" + this.basket = new ShopBasket(); + } + + @Override + public boolean isProductAdded (final Product product) { + // Must not be null + if (null == product) { + // Abort here + throw new NullPointerException("product is null"); + } + + // Has the "cache" some entries? + if (!this.basket.isEmpty()) { + // Generate fake instance + AddableBasketItem item = new BasketItem(product); + + // Then ask it about it + if (this.basket.isAdded(item)) { + // Found it + return true; + } + } + + // Generate fake instance + AddableBasketItem item = new BasketItem(product); + + // Ask bean about it + return this.basketBean.isAdded(item); } @Override @@ -87,17 +121,12 @@ public class BasketWebBean extends BaseFrameworkBean implements BasketWebControl super.genericInit(); } - @Override - public void setCurrentProduct (final Product product) { - this.currentProduct = product; - } - /** * Getter for basket bean instance - * + * * @return Basket bean instance */ private BasketSessionBeanRemote getBasketBean () { - return basketBean; + return this.basketBean; } } diff --git a/src/java/org/mxchange/pizzaapplication/beans/basket/BasketWebController.java b/src/java/org/mxchange/pizzaapplication/beans/basket/BasketWebController.java index 3f78e540..f014025f 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/basket/BasketWebController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/basket/BasketWebController.java @@ -22,7 +22,7 @@ import org.mxchange.jshopcore.model.product.Product; /** * An interface for a basket * - * @author Roland Haeder + * @author Roland Haeder */ public interface BasketWebController extends Serializable { /** @@ -40,9 +40,10 @@ public interface BasketWebController extends Serializable { public boolean hasItems (); /** - * Setter for current product instance - * + * Checks whether the currently set product is added in basked + * * @param product Product instance + * @return Whether the product is added */ - public void setCurrentProduct (final Product product); + public boolean isProductAdded (final Product product); } diff --git a/src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebBean.java index dccb3b3a..81e7d0fa 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebBean.java @@ -16,7 +16,6 @@ */ package org.mxchange.pizzaapplication.beans.category; -import java.rmi.RemoteException; import javax.enterprise.context.SessionScoped; import javax.faces.view.facelets.FaceletException; import javax.inject.Named; @@ -31,7 +30,7 @@ import org.mxchange.jshopcore.model.category.ProductCategory; /** * Main application class * - * @author Roland Haeder + * @author Roland Haeder */ @Named("admin_category") @SessionScoped @@ -79,7 +78,7 @@ public class AdminCategoryWebBean extends BaseFrameworkBean implements AdminCate // Deligate to bean this.categoryBean.doAdminAddCategory(category); - } catch (final CategoryTitleAlreadyUsedException | RemoteException ex) { + } catch (final CategoryTitleAlreadyUsedException ex) { // Continue to throw throw new FaceletException(ex); } diff --git a/src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebController.java b/src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebController.java index 2db0eb35..10e8b5f4 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebController.java @@ -21,7 +21,7 @@ import javax.faces.view.facelets.FaceletException; /** * An interface for product controllers for "ADMIN" role * - * @author Roland Haeder + * @author Roland Haeder */ public interface AdminCategoryWebController { diff --git a/src/java/org/mxchange/pizzaapplication/beans/controller/PizzaShopWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/controller/PizzaShopWebBean.java deleted file mode 100644 index 211e86c1..00000000 --- a/src/java/org/mxchange/pizzaapplication/beans/controller/PizzaShopWebBean.java +++ /dev/null @@ -1,128 +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.controller; - -import java.rmi.RemoteException; -import java.sql.SQLException; -import java.util.Deque; -import java.util.Queue; -import javax.annotation.PostConstruct; -import javax.enterprise.context.SessionScoped; -import javax.faces.FacesException; -import javax.inject.Named; -import javax.naming.InitialContext; -import javax.naming.NamingException; -import org.mxchange.jcoreee.beans.BaseFrameworkBean; -import org.mxchange.jshopcore.model.category.Category; -import org.mxchange.jshopcore.model.category.CategorySessionBeanRemote; -import org.mxchange.jshopcore.model.category.ProductCategory; -import org.mxchange.jshopcore.model.product.Product; -import org.mxchange.jshopcore.model.product.ProductSessionBeanRemote; - -/** - * Main application class - * - * @author Roland Haeder - */ -@Named("controller") -@SessionScoped -public class PizzaShopWebBean extends BaseFrameworkBean implements PizzaShopWebController { - /** - * Serial id - */ - private static final long serialVersionUID = 58_137_539_530_279L; - - /** - * Remote bean for categories - */ - private final CategorySessionBeanRemote categoryBean; - - /** - * Remote bean for products - */ - private final ProductSessionBeanRemote productBean; - - /** - * Default constructor - * - * @throws javax.naming.NamingException Something happened here? - */ - public PizzaShopWebBean () throws NamingException { - // Get initial context - InitialContext context = new InitialContext(); - - // Try to lookup the bean - this.categoryBean = (CategorySessionBeanRemote) context.lookup("ejb/stateless-category"); //NOI18N - - // Try to lookup the bean - this.productBean = (ProductSessionBeanRemote) context.lookup("ejb/stateless-product"); //NOI18N - } - - @PostConstruct - public void init () throws RuntimeException { - // Call super init first - super.genericInit(); - } - - @Override - public Queue getAvailableProducts () throws FacesException { - try { - return this.getProductBean().getAvailableProducts(); - } catch (final RemoteException ex) { - // Continue to throw - throw new FacesException(ex); - } - } - - @Override - public Queue getAllCategories () throws FacesException { - try { - // Fake zero categoryBean - Category c = new ProductCategory(0L, "Ist oberste Kategorie", 0L); - - // Get List back - Deque deque = this.getCategoryBean().getAllCategories(); - - // Add fake categoryBean - deque.addFirst(c); - - // Return it - return deque; - } catch (final SQLException ex) { - // Continue to throw - throw new FacesException(ex); - } - } - - /** - * Getter for shop remote bean - * - * @return Remote shop bean - */ - private CategorySessionBeanRemote getCategoryBean () { - return this.categoryBean; - } - - /** - * Getter for shop remote bean - * - * @return Remote shop bean - */ - private ProductSessionBeanRemote getProductBean () { - return this.productBean; - } -} diff --git a/src/java/org/mxchange/pizzaapplication/beans/controller/PizzaShopWebController.java b/src/java/org/mxchange/pizzaapplication/beans/controller/PizzaShopWebController.java deleted file mode 100644 index 4998aa4b..00000000 --- a/src/java/org/mxchange/pizzaapplication/beans/controller/PizzaShopWebController.java +++ /dev/null @@ -1,47 +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.controller; - -import java.io.Serializable; -import java.util.Queue; -import javax.faces.view.facelets.FaceletException; -import org.mxchange.jshopcore.model.category.Category; -import org.mxchange.jshopcore.model.product.Product; - -/** - * An interface for the shop - * - * @author Roland Haeder - */ -public interface PizzaShopWebController extends Serializable { - - /** - * Some "getter" for a linked list of only available products - * - * @return Only available products - * @throws javax.faces.view.facelets.FaceletException If anything went wrong - */ - public Queue getAvailableProducts () throws FaceletException; - - /** - * Some "getter" for a linked list of all categories - * - * @return All categories - * @throws javax.faces.view.facelets.FaceletException If anything went wrong - */ - public Queue getAllCategories () throws FaceletException; -} diff --git a/src/java/org/mxchange/pizzaapplication/beans/controller/ShopWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/controller/ShopWebBean.java new file mode 100644 index 00000000..d2b33be9 --- /dev/null +++ b/src/java/org/mxchange/pizzaapplication/beans/controller/ShopWebBean.java @@ -0,0 +1,126 @@ +/* + * 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.controller; + +import java.util.Deque; +import java.util.Queue; +import javax.annotation.PostConstruct; +import javax.enterprise.context.SessionScoped; +import javax.faces.FacesException; +import javax.faces.view.facelets.FaceletException; +import javax.inject.Named; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import org.mxchange.jcoreee.beans.BaseFrameworkBean; +import org.mxchange.jshopcore.model.category.Category; +import org.mxchange.jshopcore.model.category.CategorySessionBeanRemote; +import org.mxchange.jshopcore.model.category.ProductCategory; +import org.mxchange.jshopcore.model.product.Product; +import org.mxchange.jshopcore.model.product.ProductSessionBeanRemote; + +/** + * Main application class + * + * @author Roland Haeder + */ +@Named("controller") +@SessionScoped +public class ShopWebBean extends BaseFrameworkBean implements ShopWebController { + /** + * Serial id + */ + private static final long serialVersionUID = 58_137_539_530_279L; + + /** + * Remote bean for categories + */ + private final CategorySessionBeanRemote categoryBean; + + /** + * Remote bean for products + */ + private final ProductSessionBeanRemote productBean; + + /** + * Default constructor + * + * @throws javax.naming.NamingException Something happened here? + */ + public ShopWebBean () throws NamingException { + // Get initial context + InitialContext context = new InitialContext(); + + // Try to lookup the bean + this.categoryBean = (CategorySessionBeanRemote) context.lookup("ejb/stateless-category"); //NOI18N + + // Try to lookup the bean + this.productBean = (ProductSessionBeanRemote) context.lookup("ejb/stateless-product"); //NOI18N + } + + @Override + public Deque getAllCategories () throws FacesException { + // Get List back + Deque deque = this.getCategoryBean().getAllCategories(); + + // Return it + return deque; + } + + @Override + public Deque getAllCategoriesParent () throws FaceletException { + // Get regular list + Deque deque = this.getAllCategories(); + + // Create fake entry + Category fake = new ProductCategory(0L, this.getMessage("Category.has_no_parent_category"), 0L); //NOI18N + + // Add it + deque.addFirst(fake); + + // Return it + return deque; + } + + @Override + public Queue getAvailableProducts () throws FacesException { + return this.getProductBean().getAvailableProducts(); + } + + @PostConstruct + public void init () { + // Call super init for getting resource bundle + super.genericInit(); + } + + /** + * Getter for shop remote bean + * + * @return Remote shop bean + */ + private CategorySessionBeanRemote getCategoryBean () { + return this.categoryBean; + } + + /** + * Getter for shop remote bean + * + * @return Remote shop bean + */ + private ProductSessionBeanRemote getProductBean () { + return this.productBean; + } +} diff --git a/src/java/org/mxchange/pizzaapplication/beans/controller/ShopWebController.java b/src/java/org/mxchange/pizzaapplication/beans/controller/ShopWebController.java new file mode 100644 index 00000000..547c66e9 --- /dev/null +++ b/src/java/org/mxchange/pizzaapplication/beans/controller/ShopWebController.java @@ -0,0 +1,57 @@ +/* + * 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.controller; + +import java.io.Serializable; +import java.util.Deque; +import java.util.Queue; +import javax.faces.view.facelets.FaceletException; +import org.mxchange.jshopcore.model.category.Category; +import org.mxchange.jshopcore.model.product.Product; + +/** + * An interface for the shop + * + * @author Roland Haeder + */ +public interface ShopWebController extends Serializable { + + /** + * Some "getter" for a linked list of only available products + * + * @return Only available products + * @throws javax.faces.view.facelets.FaceletException If anything went wrong + */ + public Queue getAvailableProducts () throws FaceletException; + + /** + * Some "getter" for a linked list of all categories + * + * @return All categories + * @throws javax.faces.view.facelets.FaceletException If anything went wrong + */ + public Deque getAllCategories () throws FaceletException; + + /** + * Some "getter" for a linked list of all categories including "Has no + * parent" fake category. + * + * @return All categories + * @throws javax.faces.view.facelets.FaceletException If anything went wrong + */ + public Deque getAllCategoriesParent () throws FaceletException; +} diff --git a/src/java/org/mxchange/pizzaapplication/beans/customer/CustomerWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/customer/CustomerWebBean.java index 703a87dc..d8d86e8e 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/customer/CustomerWebBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/customer/CustomerWebBean.java @@ -28,7 +28,7 @@ import org.mxchange.jshopcore.model.customer.CustomerSessionBeanRemote; /** * A customer bean which hides the customer instance * - * @author Roland Haeder + * @author Roland Haeder */ @Named("customer") @SessionScoped diff --git a/src/java/org/mxchange/pizzaapplication/beans/customer/CustomerWebController.java b/src/java/org/mxchange/pizzaapplication/beans/customer/CustomerWebController.java index 6ee25f7b..691211b5 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/customer/CustomerWebController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/customer/CustomerWebController.java @@ -22,7 +22,7 @@ import org.mxchange.jcore.model.contact.gender.Gender; /** * An interface for customer beans * - * @author Roland Haeder + * @author Roland Haeder */ public interface CustomerWebController extends Serializable { diff --git a/src/java/org/mxchange/pizzaapplication/beans/gender/GenderWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/gender/GenderWebBean.java index b993c1a4..e15647c0 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/gender/GenderWebBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/gender/GenderWebBean.java @@ -28,7 +28,7 @@ import org.mxchange.jcoreee.beans.BaseFrameworkBean; /** * A customer bean which hides the customer instance * - * @author Roland Haeder + * @author Roland Haeder */ @Named ("gender") @ApplicationScoped diff --git a/src/java/org/mxchange/pizzaapplication/beans/gender/GenderWebController.java b/src/java/org/mxchange/pizzaapplication/beans/gender/GenderWebController.java index 48e2e8af..7fa87790 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/gender/GenderWebController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/gender/GenderWebController.java @@ -23,7 +23,7 @@ import org.mxchange.jcore.model.contact.gender.Gender; /** * An interface for data beans * - * @author Roland Haeder + * @author Roland Haeder */ public interface GenderWebController extends Serializable { diff --git a/src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebBean.java index 5ab300db..c3de01c0 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebBean.java @@ -16,39 +16,61 @@ */ package org.mxchange.pizzaapplication.beans.product; -import java.rmi.RemoteException; import java.util.Deque; -import javax.enterprise.context.SessionScoped; +import javax.enterprise.context.ApplicationScoped; import javax.faces.view.facelets.FaceletException; import javax.inject.Named; import javax.naming.InitialContext; import javax.naming.NamingException; import org.mxchange.jcoreee.beans.BaseFrameworkBean; import org.mxchange.jshopcore.exceptions.ProductTitleAlreadyUsedException; +import org.mxchange.jshopcore.model.product.GenericProduct; import org.mxchange.jshopcore.model.product.Product; import org.mxchange.jshopcore.model.product.ProductSessionBeanRemote; /** * Main application class * - * @author Roland Haeder + * @author Roland Haeder */ -@Named("admin_product") -@SessionScoped +@Named ("admin_product") +@ApplicationScoped public class AdminProductWebBean extends BaseFrameworkBean implements AdminProductWebController { + /** * Serial id */ private static final long serialVersionUID = 5_819_375_183_472_871L; + + + /** + * Property available + */ + private Boolean available; + + /** + * Category id + */ + private Long categoryId; + + /** + * Property price + */ + private Float price; /** * Remote bean for products */ - private final ProductSessionBeanRemote product; + private final ProductSessionBeanRemote productBean; + + /** + * Property title + */ + private String title; /** * Default constructor - * + * * @throws javax.naming.NamingException Something happened here? */ public AdminProductWebBean () throws NamingException { @@ -56,14 +78,29 @@ public class AdminProductWebBean extends BaseFrameworkBean implements AdminProdu InitialContext context = new InitialContext(); // Try to lookup the bean - this.product = (ProductSessionBeanRemote) context.lookup("ejb/stateless-product"); //NOI18N + this.productBean = (ProductSessionBeanRemote) context.lookup("ejb/stateless-product"); //NOI18N } @Override - public void doAdminAddProduct (final Product product) throws FaceletException { + public void addProduct () throws FaceletException { try { + // Create product instance + Product product = new GenericProduct(); + + // Add all + product.setAvailable(this.getAvailable()); + product.setCategoryId(this.getCategoryId()); + product.setPrice(this.getPrice()); + product.setTitle(this.getTitle()); + // Call bean - this.product.doAdminAddProduct(product); + this.productBean.doAdminAddProduct(product); + + // Set all to null + this.setAvailable(Boolean.FALSE); + this.setCategoryId(null); + this.setPrice(null); + this.setTitle(null); } catch (final ProductTitleAlreadyUsedException ex) { // Continue to throw throw new FaceletException(ex); @@ -72,12 +109,47 @@ public class AdminProductWebBean extends BaseFrameworkBean implements AdminProdu @Override public Deque getAllProducts () throws FaceletException { - try { - // Call bean - return this.product.getAllProducts(); - } catch (final RemoteException ex) { - // Continue to throw - throw new FaceletException(ex); - } + // Call bean + return this.productBean.getAllProducts(); + } + + @Override + public void setAvailable (final Boolean available) { + this.available = available; + } + + @Override + public Long getCategoryId () { + return categoryId; + } + + @Override + public void setCategoryId (Long categoryId) { + this.categoryId = categoryId; + } + + @Override + public Float getPrice () { + return this.price; + } + + @Override + public void setPrice (final Float price) { + this.price = price; + } + + @Override + public String getTitle () { + return this.title; + } + + @Override + public void setTitle (final String title) { + this.title = title; + } + + @Override + public Boolean getAvailable () { + return this.available; } } diff --git a/src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebController.java b/src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebController.java index a77b18db..23fc5c65 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebController.java @@ -23,17 +23,16 @@ import org.mxchange.jshopcore.model.product.Product; /** * An interface for product controllers for "ADMIN" role * - * @author Roland Haeder + * @author Roland Haeder */ public interface AdminProductWebController { /** * Adds given product data from request to database * - * @param product Product instance * @throws javax.faces.view.facelets.FaceletException If something unexpected happened */ - public void doAdminAddProduct (final Product product) throws FaceletException; + public void addProduct () throws FaceletException; /** * Some "getter" for a linked list of all products @@ -42,4 +41,60 @@ public interface AdminProductWebController { * @throws javax.faces.view.facelets.FaceletException If anything went wrong */ public Deque getAllProducts () throws FaceletException; + + /** + * Getter for product's title property + * + * @return Product's title + */ + public String getTitle (); + + /** + * Setter for product's title property + * + * @param title Product's title + */ + public void setTitle (final String title); + + /** + * Getter for product's price property + * + * @return Product's price property + */ + public Float getPrice (); + + /** + * Setter for product's price property + * + * @param price Product's price property + */ + public void setPrice (final Float price); + + /** + * Setter for product's available property + * + * @param available Product's available property + */ + public void setAvailable (final Boolean available); + + /** + * Getter for product's available property + * + * @return Product's available property + */ + public Boolean getAvailable (); + + /** + * Getter for product's category id + * + * @return Product's category id + */ + public Long getCategoryId (); + + /** + * Setter for product's category id + * + * @param categoryId Product's category id + */ + public void setCategoryId (final Long categoryId); } diff --git a/web/WEB-INF/templates/admin/admin_category_selection_box.tpl b/web/WEB-INF/templates/admin/admin_category_selection_box.tpl index e986ccec..2ae89974 100644 --- a/web/WEB-INF/templates/admin/admin_category_selection_box.tpl +++ b/web/WEB-INF/templates/admin/admin_category_selection_box.tpl @@ -4,7 +4,7 @@ xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"> - + diff --git a/web/WEB-INF/templates/admin/admin_parent_category_selection_box.tpl b/web/WEB-INF/templates/admin/admin_parent_category_selection_box.tpl index 8b6d8815..c3251221 100644 --- a/web/WEB-INF/templates/admin/admin_parent_category_selection_box.tpl +++ b/web/WEB-INF/templates/admin/admin_parent_category_selection_box.tpl @@ -4,7 +4,7 @@ xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"> - - + + diff --git a/web/admin/category.xhtml b/web/admin/category.xhtml index d00596f5..53d89251 100644 --- a/web/admin/category.xhtml +++ b/web/admin/category.xhtml @@ -19,7 +19,7 @@
- + Auswählen: #{cat.categoryId}: @@ -33,8 +33,7 @@ Elternkategorie: - #{cat.categoryId}: - #{controller.generateLinkForParent(cat)} + #{cat.parentId} diff --git a/web/admin/product.xhtml b/web/admin/product.xhtml index 30039b91..2d8f6df0 100644 --- a/web/admin/product.xhtml +++ b/web/admin/product.xhtml @@ -19,11 +19,10 @@
- + Produktnummer: - #{pro.id}: - + #{pro.id}: @@ -36,17 +35,17 @@ Kategorie: - ${controller.getPrintableProduktCategory(product)} + #{pro.categoryId} Verfügbar: - ${controller.getPrintableProductAvailability(product)} + #{pro.available} @@ -69,7 +68,7 @@
- +
@@ -82,7 +81,7 @@
- +
@@ -106,10 +105,10 @@
- + + + +
diff --git a/web/index.xhtml b/web/index.xhtml index c8f01264..05ae23e3 100644 --- a/web/index.xhtml +++ b/web/index.xhtml @@ -65,10 +65,7 @@ - - - - + @@ -96,10 +93,10 @@ - + - +