]> git.mxchange.org Git - pizzaservice-war.git/commitdiff
Updated author (email address) + jars + implemented very basic basket
authorRoland Haeder <roland@mxchange.org>
Thu, 10 Sep 2015 13:40:33 +0000 (15:40 +0200)
committerRoland Haeder <roland@mxchange.org>
Thu, 10 Sep 2015 13:40:33 +0000 (15:40 +0200)
Signed-off-by:Roland Häder <roland@mxchange.org>

25 files changed:
lib/jcore-ee-logger.jar
lib/jcoreee.jar
lib/jshop-core.jar
lib/jshop-ee-lib.jar
src/java/org/mxchange/localization/bundle_de_DE.properties
src/java/org/mxchange/localization/bundle_en_US.properties
src/java/org/mxchange/pizzaapplication/beans/basket/BasketWebBean.java
src/java/org/mxchange/pizzaapplication/beans/basket/BasketWebController.java
src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebBean.java
src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebController.java
src/java/org/mxchange/pizzaapplication/beans/controller/PizzaShopWebBean.java [deleted file]
src/java/org/mxchange/pizzaapplication/beans/controller/PizzaShopWebController.java [deleted file]
src/java/org/mxchange/pizzaapplication/beans/controller/ShopWebBean.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/beans/controller/ShopWebController.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/beans/customer/CustomerWebBean.java
src/java/org/mxchange/pizzaapplication/beans/customer/CustomerWebController.java
src/java/org/mxchange/pizzaapplication/beans/gender/GenderWebBean.java
src/java/org/mxchange/pizzaapplication/beans/gender/GenderWebController.java
src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebBean.java
src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebController.java
web/WEB-INF/templates/admin/admin_category_selection_box.tpl
web/WEB-INF/templates/admin/admin_parent_category_selection_box.tpl
web/admin/category.xhtml
web/admin/product.xhtml
web/index.xhtml

index 5ebf6d07bb973bde224c28c9e8403af3719390fe..c65212243809f11f3ffb24a9b60a199155e03c07 100644 (file)
Binary files a/lib/jcore-ee-logger.jar and b/lib/jcore-ee-logger.jar differ
index 963ff769842e10dc653a66a7c0a12233947fe660..935a2c95c4a2c3876bdb5fbc0aa3c28141edb024 100644 (file)
Binary files a/lib/jcoreee.jar and b/lib/jcoreee.jar differ
index 8bd977aceaa10e6d584bd3c58fd6d2533a5dbf5f..4b07e19ee3c21d6130ea27bfdeeeb563eda320bc 100644 (file)
Binary files a/lib/jshop-core.jar and b/lib/jshop-core.jar differ
index 004480c6f93632dea08a72bd7b579705f9bfb815..f077244855e9b65095a8c2e9c89ad0c0e558305f 100644 (file)
Binary files a/lib/jshop-ee-lib.jar and b/lib/jshop-ee-lib.jar differ
index f13ba2385ea3917ae0218d1810acc49cf04b55f7..4d740b5e6ac6ce7414b3b2d41fbedb49021068e4 100644 (file)
@@ -21,3 +21,6 @@ MiniBasketTag.last_item=Zuletzt hinzugef&uuml;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
index 1dc42122a0008bbe84600d532a56b28281a10552..99889ee9a5cb74e4b6b20edfb12f080fb005d323 100644 (file)
@@ -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
index ce7822146546d1e82476688773d5b27013e48ad6..f2b30cb783745a5a969d5683dd560b3691447642 100644 (file)
@@ -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<roland@mxchange.org>
  */
-@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<AddableBasketItem> 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;
        }
 }
index 3f78e540f5a1da4adb63f2ecc68a91c54c7dba26..f014025f6a208a6f1df7c6e0013cfc21353dfceb 100644 (file)
@@ -22,7 +22,7 @@ import org.mxchange.jshopcore.model.product.Product;
 /**
  * An interface for a basket
  *
- * @author Roland Haeder
+ * @author Roland Haeder<roland@mxchange.org>
  */
 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);
 }
index dccb3b3a42fff05ce296bcbfe2882c708539d423..81e7d0faebd3c9ae19e0cea5cd51a3a4c50a082f 100644 (file)
@@ -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<roland@mxchange.org>
  */
 @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);
                }
index 2db0eb353000b493cda3c129f0bd1aa937a75a6c..10e8b5f4b051eb5041caa56c4c38363b99ec5cf1 100644 (file)
@@ -21,7 +21,7 @@ import javax.faces.view.facelets.FaceletException;
 /**
  * An interface for product controllers for "ADMIN" role
  *
- * @author Roland Haeder
+ * @author Roland Haeder<roland@mxchange.org>
  */
 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 (file)
index 211e86c..0000000
+++ /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 <http://www.gnu.org/licenses/>.
- */
-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<Product> getAvailableProducts () throws FacesException {
-               try {
-                       return this.getProductBean().getAvailableProducts();
-               } catch (final RemoteException ex) {
-                       // Continue to throw
-                       throw new FacesException(ex);
-               }
-       }
-
-       @Override
-       public Queue<Category> getAllCategories () throws FacesException {
-               try {
-                       // Fake zero categoryBean
-                       Category c = new ProductCategory(0L, "Ist oberste Kategorie", 0L);
-
-                       // Get List back
-                       Deque<Category> 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 (file)
index 4998aa4..0000000
+++ /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 <http://www.gnu.org/licenses/>.
- */
-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<Product> 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<Category> 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 (file)
index 0000000..d2b33be
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+ */
+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<roland@mxchange.org>
+ */
+@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<Category> getAllCategories () throws FacesException {
+               // Get List back
+               Deque<Category> deque = this.getCategoryBean().getAllCategories();
+
+               // Return it
+               return deque;
+       }
+
+       @Override
+       public Deque<Category> getAllCategoriesParent () throws FaceletException {
+               // Get regular list
+               Deque<Category> 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<Product> 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 (file)
index 0000000..547c66e
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+ */
+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<roland@mxchange.org>
+ */
+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<Product> 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<Category> 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<Category> getAllCategoriesParent () throws FaceletException;
+}
index 703a87dccfa1088b75f7a74284f0bb3de553836c..d8d86e8e0fd5640a676677f4c7b7147d7ac1a87b 100644 (file)
@@ -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<roland@mxchange.org>
  */
 @Named("customer")
 @SessionScoped
index 6ee25f7b5cbd04093abf5fd7da41146cec30697c..691211b5a95d3d30ed9badfec68c4eb145a2c6c0 100644 (file)
@@ -22,7 +22,7 @@ import org.mxchange.jcore.model.contact.gender.Gender;
 /**
  * An interface for customer beans
  *
- * @author Roland Haeder
+ * @author Roland Haeder<roland@mxchange.org>
  */
 public interface CustomerWebController extends Serializable {
 
index b993c1a4db6fdb587fc455adf2deb03322feaa44..e15647c00f6360986cff49c7f1b2ec76280944ca 100644 (file)
@@ -28,7 +28,7 @@ import org.mxchange.jcoreee.beans.BaseFrameworkBean;
 /**
  * A customer bean which hides the customer instance
  *
- * @author Roland Haeder
+ * @author Roland Haeder<roland@mxchange.org>
  */
 @Named ("gender")
 @ApplicationScoped
index 48e2e8afb453b1e071d4cfd3263b075fda1d9565..7fa87790299df65d723cb65e2fb73ebf91f52db9 100644 (file)
@@ -23,7 +23,7 @@ import org.mxchange.jcore.model.contact.gender.Gender;
 /**
  * An interface for data beans
  *
- * @author Roland Haeder
+ * @author Roland Haeder<roland@mxchange.org>
  */
 public interface GenderWebController extends Serializable {
 
index 5ab300db26f54ac9e0460243abdff751d66d1b5a..c3de01c0b37798beff12eaeea82d9654e818a97c 100644 (file)
  */
 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<roland@mxchange.org>
  */
-@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<Product> 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;
        }
 }
index a77b18db0443503b20821c3e5798f2e71c0b2f9f..23fc5c65f16594bda30e1769e48361d6b0564a9d 100644 (file)
@@ -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<roland@mxchange.org>
  */
 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<Product> 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);
 }
index e986ccec17c3338dc17f1a89642c334ce6f6702a..2ae8997486b2a6063744d1787e9c49447c0d27cf 100644 (file)
@@ -4,7 +4,7 @@
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:ui="http://java.sun.com/jsf/facelets">
 
-       <h:selectOneMenu class="select" id="category">
+       <h:selectOneMenu class="select" id="categoryId" value="#{admin_product.categoryId}">
                <f:selectItems value="#{controller.allCategories}" var="cat" itemValue="#{cat.categoryId}" itemLabel="#{cat.title}" />
        </h:selectOneMenu>
 </ui:composition>
index 8b6d8815993ae642830bd7ffb979b4ce452ef6a8..c3251221fa8dbbc387f3550e4506e3e5f146b29b 100644 (file)
@@ -4,7 +4,7 @@
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:ui="http://java.sun.com/jsf/facelets">
 
-       <h:selectOneMenu class="select" id="parentId">
-               <f:selectItems value="#{controller.allCategories}" var="parent_category" itemValue="#{parent_category.categoryId}" itemLabel="#{parent_category.title}" />
+       <h:selectOneMenu class="select" id="parentId" value="#{admin_category.parentId}">
+               <f:selectItems value="#{controller.allCategoriesParent}" var="parent_category" itemValue="#{parent_category.categoryId}" itemLabel="#{parent_category.title}" />
        </h:selectOneMenu>
 </ui:composition>
index d00596f537e1555f2cb98072a5ec29aae5988f72..53d8925199c3cd95d0a11dac1be70d395ae2513c 100644 (file)
@@ -19,7 +19,7 @@
                <ui:define name="content">
                        <div class="para">
                                <h:form acceptcharset="utf-8" id="form">
-                                       <h:dataTable headerClass="table_header_column" rowClasses="table_row" styleClass="table" id="categories" value="#{controller.allCategories}" var="cat" rendered="#{cat != null}">
+                                       <h:dataTable headerClass="table_header_column" rowClasses="table_row" styleClass="table" id="categories" value="#{controller.allCategories}" var="cat">
                                                <h:column>
                                                        <f:facet name="header">Auswählen:</f:facet>
                                                        #{cat.categoryId}:
@@ -33,8 +33,7 @@
 
                                                <h:column>
                                                        <f:facet name="header">Elternkategorie:</f:facet>
-                                                       #{cat.categoryId}:
-                                                       #{controller.generateLinkForParent(cat)}
+                                                       #{cat.parentId}
                                                </h:column>
                                        </h:dataTable>
 
index 30039b91a9c652961cc641458b07f5a473007acd..2d8f6df0875ba81029623f9f291bce61e05e35c3 100644 (file)
                <ui:define name="content">
                        <div class="para">
                                <h:form acceptcharset="utf-8" id="form">
-                                       <h:dataTable columnClasses="table_row" headerClass="table_header_column" id="product_table" var="pro" value="#{admin_product.allProducts}">
+                                       <h:dataTable headerClass="table_header_column" id="product_table" var="pro" value="#{admin_product.allProducts}">
                                                <h:column>
                                                        <f:facet name="header">Produktnummer:</f:facet>
-                                                       #{pro.id}:
-                                                       <h:selectBooleanCheckbox class="input" value="true" />
+                                                       #{pro.id}:<h:selectBooleanCheckbox class="input" value="true" />
                                                </h:column>
 
                                                <h:column>
                                                </h:column>
                                                <h:column>
                                                        <f:facet name="header">Kategorie:</f:facet>
-                                                       ${controller.getPrintableProduktCategory(product)}
+                                                       #{pro.categoryId}
                                                </h:column>
                                                <h:column>
                                                        <f:facet name="header">Verfügbar:</f:facet>
-                                                       ${controller.getPrintableProductAvailability(product)}
+                                                       #{pro.available}
                                                </h:column>
                                        </h:dataTable>
 
                                        <div  class="table_footer">
                                                <h:commandButton class="reset" type="reset" value="Formular zurücksetzen" />
-                                               <h:commandButton class="submit" type="submit" id="edit" action="#{admin_product.ediProduct(product)}" value="Ändern" />
+                                               <h:commandButton class="submit" type="submit" id="edit" action="#{admin_product.editProduct(product)}" value="Ändern" />
                                                <h:commandButton class="delete" type="submit" id="delete" action="#{admin_category.deleteProduct(product)}" value="Löschen" />
                                        </div>
                                </h:form>
@@ -69,7 +68,7 @@
                                                        </div>
 
                                                        <div class="table_right">
-                                                               <h:inputText class="input" id="title" size="10" maxlength="255" />
+                                                               <h:inputText class="input" id="title" size="10" maxlength="255" required="true" value="#{admin_product.title}" />
                                                        </div>
 
                                                        <div class="clear"></div>
@@ -82,7 +81,7 @@
                                                        </div>
 
                                                        <div class="table_right">
-                                                               <h:inputText class="input" id="price" size="10" maxlength="255" />
+                                                               <h:inputText class="input" id="price" size="10" maxlength="255" required="true" value="#{admin_product.price}" />
                                                        </div>
 
                                                        <div class="clear"></div>
                                                        </div>
 
                                                        <div class="table_right">
-                                                               <select class="select" name="available" size="1">
-                                                                       <option value="true">Ja</option>
-                                                                       <option value="false">Nein</option>
-                                                               </select>
+                                                               <h:selectOneListbox required="true" id="available" value="#{admin_product.available}" size="1" class="select">
+                                                                       <f:selectItem itemValue="true" itemLabel="#{msg.Generic_YES}" />
+                                                                       <f:selectItem itemValue="false" itemLabel="#{msg.Generic_NO}" />
+                                                               </h:selectOneListbox>
                                                        </div>
 
                                                        <div class="clear"></div>
index c8f01264c467f0bca3b3791f1c93fc4b08b10e7f..05ae23e341c0747852bdf5903e6b7295205f956c 100644 (file)
                                <tbody>
                                        <ui:repeat var="product" value="#{controller.availableProducts}">
                                                <h:form acceptcharset="utf-8" id="add_item">
-
-                                                       <f:viewAction action="#{basket.setCurrentProduct(product)}" />
-
-                                                       <ui:fragment rendered="#{basket.isCurrentProductAdded() == true}">
+                                                       <ui:fragment rendered="#{basket.isProductAdded(product) == true}">
                                                                <tr>
                                                                        <td class="table_data_column">
                                                                                <h:link outcome="basket" title="Zum Warenkorb" value="Warenkorb" />
                                                                </tr>
                                                        </ui:fragment>
 
-                                                       <ui:fragment rendered="#{basket.isCurrentProductAdded() == false}">
+                                                       <ui:fragment rendered="#{basket.isProductAdded(product) == false}">
                                                                <tr>
                                                                        <td class="table_data_column">
-                                                                               <h:commandButton class="submit" id="add" value="Hinzufügen" action="#{basket.addToBasket(product)}" />
+                                                                               <h:commandButton class="submit" id="add" value="Hinzufügen" action="#{basket.addItem(product)}" />
                                                                                <h:inputHidden id="itemId" value="#{product.id}" />
                                                                                <h:inputHidden id="itemType" value="Product" />
                                                                        </td>