--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.pizzaapplication.beans.category;
+
+import java.util.LinkedList;
+import java.util.List;
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.event.Observes;
+import javax.faces.FacesException;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Named;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jshopcore.events.category.AddedCategoryEvent;
+import org.mxchange.jshopcore.model.category.Category;
+import org.mxchange.jshopcore.model.category.CategorySessionBeanRemote;
+
+/**
+ * General (product) category controller
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@Named ("categoryController")
+@ApplicationScoped
+public class PizzaCategoryWebApplicationBean implements PizzaCategoryWebApplicationController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 58_137_539_530_279L;
+
+ /**
+ * All categories
+ */
+ private List<Category> categories;
+
+ @Override
+ public void addCategory (final Category category) {
+ // Add the category
+ this.categories.add(category);
+ }
+
+ @Override
+ public void afterShopCategoryAdded (@Observes final AddedCategoryEvent event) {
+ // Add it here, too.
+ this.addCategory(event.getAddedCategory());
+ }
+
+ @Override
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public List<Category> getAllCategories () throws FacesException {
+ // Return it
+ return this.categories;
+ }
+
+ @Override
+ public List<Category> getAllCategoriesParent () throws FaceletException {
+ // Get regular list
+ List<Category> list = new LinkedList<>(this.getAllCategories());
+
+ // Return it
+ return list;
+ }
+
+ /**
+ * Initialization of this bean
+ */
+ @PostConstruct
+ public void init () {
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup the bean
+ CategorySessionBeanRemote categoryBean = (CategorySessionBeanRemote) context.lookup("java:global/jshop-ejb/category!org.mxchange.jshopcore.model.category.CategorySessionBeanRemote"); //NOI18N
+
+ // Get all categories
+ this.categories = categoryBean.getAllCategories();
+ } catch (final NamingException e) {
+ // Continued to throw
+ throw new FacesException(e);
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.pizzaapplication.beans.category;
+
+import java.io.Serializable;
+import java.util.List;
+import javax.faces.view.facelets.FaceletException;
+import org.mxchange.jshopcore.events.category.AddedCategoryEvent;
+import org.mxchange.jshopcore.model.category.Category;
+
+/**
+ * An interface for (product) categories
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public interface PizzaCategoryWebApplicationController extends Serializable {
+
+ /**
+ * Adds given category to the "cached" instance
+ * <p>
+ * @param category Category instance
+ */
+ void addCategory (final Category category);
+
+ /**
+ * Some "getter" for a linked list of all categories
+ * <p>
+ * @return All categories
+ * <p>
+ * @throws javax.faces.view.facelets.FaceletException If anything went wrong
+ */
+ List<Category> getAllCategories () throws FaceletException;
+
+ /**
+ * Some "getter" for a linked list of all categories including "Has no
+ * parent" fake category.
+ * <p>
+ * @return All categories
+ * <p>
+ * @throws javax.faces.view.facelets.FaceletException If anything went wrong
+ */
+ List<Category> getAllCategoriesParent () throws FaceletException;
+
+ /**
+ * Observes events fired after a new product category has been added
+ * <p>
+ * @param event Event to be observed
+ */
+ void afterShopCategoryAdded (final AddedCategoryEvent event);
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.pizzaapplication.beans.product;
+
+import java.util.Collections;
+import java.util.List;
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.event.Observes;
+import javax.faces.FacesException;
+import javax.inject.Named;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jshopcore.events.product.AddedProductEvent;
+import org.mxchange.jshopcore.model.product.Product;
+import org.mxchange.jshopcore.model.product.ProductSessionBeanRemote;
+
+/**
+ * General product controller
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@Named ("productController")
+@ApplicationScoped
+public class PizzaProductWebApplicationBean implements PizzaProductWebApplicationController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 58_137_539_530_279L;
+
+ /**
+ * "Cache" for all available products
+ */
+ private List<Product> availableProducts;
+
+ @Override
+ public void addProduct (final Product product) {
+ // Is the product available?
+ if (product.getProductAvailability()) {
+ // Add it
+ this.availableProducts.add(product);
+ }
+ }
+
+ @Override
+ public void afterShopProductAdded (@Observes final AddedProductEvent event) {
+ // Add it here, too.
+ this.addProduct(event.getAddedProduct());
+ }
+
+ @Override
+ public List<Product> getAvailableProducts () throws FacesException {
+ // Return it
+ return Collections.unmodifiableList(this.availableProducts);
+ }
+
+ /**
+ * Initialization of this bean
+ */
+ @PostConstruct
+ public void init () {
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup the bean
+ ProductSessionBeanRemote productBean = (ProductSessionBeanRemote) context.lookup("java:global/jshop-ejb/product!org.mxchange.jshopcore.model.product.ProductSessionBeanRemote"); //NOI18N
+
+ // Get available products list
+ this.availableProducts = productBean.getAvailableProducts();
+ } catch (final NamingException e) {
+ // Continued to throw
+ throw new FacesException(e);
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.pizzaapplication.beans.product;
+
+import java.io.Serializable;
+import java.util.List;
+import javax.faces.view.facelets.FaceletException;
+import org.mxchange.jshopcore.events.product.AddedProductEvent;
+import org.mxchange.jshopcore.model.product.Product;
+
+/**
+ * An interface for products
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public interface PizzaProductWebApplicationController extends Serializable {
+
+ /**
+ * Adds given product to the "cached" instance
+ * <p>
+ * @param product Product instance
+ */
+ void addProduct (final Product product);
+
+ /**
+ * Some "getter" for a linked list of only available products
+ * <p>
+ * @return Only available products
+ * <p>
+ * @throws javax.faces.view.facelets.FaceletException If anything went wrong
+ */
+ List<Product> getAvailableProducts () throws FaceletException;
+
+ /**
+ * Observes events fired after a new product has been added
+ * <p>
+ * @param event Event to be observed
+ * @todo Move this to own controller
+ */
+ void afterShopProductAdded (final AddedProductEvent event);
+
+}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Haeder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero 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 Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.pizzaapplication.beans.shop;
-
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import javax.annotation.PostConstruct;
-import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.event.Observes;
-import javax.faces.FacesException;
-import javax.faces.view.facelets.FaceletException;
-import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.jshopcore.events.category.AddedCategoryEvent;
-import org.mxchange.jshopcore.events.product.AddedProductEvent;
-import org.mxchange.jshopcore.model.category.Category;
-import org.mxchange.jshopcore.model.category.CategorySessionBeanRemote;
-import org.mxchange.jshopcore.model.product.Product;
-import org.mxchange.jshopcore.model.product.ProductSessionBeanRemote;
-
-/**
- * General shop controller
- * <p>
- * @author Roland Haeder<roland@mxchange.org>
- */
-@Named ("shopController")
-@ApplicationScoped
-public class PizzaShopWebApplicationBean implements PizzaShopWebApplicationController {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 58_137_539_530_279L;
-
- /**
- * "Cache" for all available products
- */
- private List<Product> availableProducts;
-
- /**
- * All categories
- */
- private List<Category> categories;
-
- @Override
- public void addCategory (final Category category) {
- // Add the category
- this.categories.add(category);
- }
-
- @Override
- public void addProduct (final Product product) {
- // Is the product available?
- if (product.getProductAvailability()) {
- // Add it
- this.availableProducts.add(product);
- }
- }
-
- @Override
- public void afterShopCategoryAdded (@Observes final AddedCategoryEvent event) {
- // Add it here, too.
- this.addCategory(event.getAddedCategory());
- }
-
- @Override
- public void afterShopProductAdded (@Observes final AddedProductEvent event) {
- // Add it here, too.
- this.addProduct(event.getAddedProduct());
- }
-
- @Override
- @SuppressWarnings ("ReturnOfCollectionOrArrayField")
- public List<Category> getAllCategories () throws FacesException {
- // Return it
- return this.categories;
- }
-
- @Override
- public List<Category> getAllCategoriesParent () throws FaceletException {
- // Get regular list
- List<Category> list = new LinkedList<>(this.getAllCategories());
-
- // Return it
- return list;
- }
-
- @Override
- public List<Product> getAvailableProducts () throws FacesException {
- // Return it
- return Collections.unmodifiableList(this.availableProducts);
- }
-
- /**
- * Initialization of this bean
- */
- @PostConstruct
- public void init () {
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Try to lookup the bean
- CategorySessionBeanRemote categoryBean = (CategorySessionBeanRemote) context.lookup("java:global/jshop-ejb/category!org.mxchange.jshopcore.model.category.CategorySessionBeanRemote"); //NOI18N
-
- // Get all categories
- this.categories = categoryBean.getAllCategories();
-
- // Try to lookup the bean
- ProductSessionBeanRemote productBean = (ProductSessionBeanRemote) context.lookup("java:global/jshop-ejb/product!org.mxchange.jshopcore.model.product.ProductSessionBeanRemote"); //NOI18N
-
- // Get available products list
- this.availableProducts = productBean.getAvailableProducts();
- } catch (final NamingException e) {
- // Continued to throw
- throw new FacesException(e);
- }
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Haeder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero 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 Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.pizzaapplication.beans.shop;
-
-import java.io.Serializable;
-import java.util.List;
-import javax.faces.view.facelets.FaceletException;
-import org.mxchange.jshopcore.events.category.AddedCategoryEvent;
-import org.mxchange.jshopcore.events.product.AddedProductEvent;
-import org.mxchange.jshopcore.model.category.Category;
-import org.mxchange.jshopcore.model.product.Product;
-
-/**
- * An interface for the shop
- * <p>
- * @author Roland Haeder<roland@mxchange.org>
- */
-public interface PizzaShopWebApplicationController extends Serializable {
-
- /**
- * Adds given category to the "cached" instance
- * <p>
- * @param category Category instance
- * @todo Move this to own controller
- */
- void addCategory (final Category category);
-
- /**
- * Adds given product to the "cached" instance
- * <p>
- * @param product Product instance
- */
- void addProduct (final Product product);
-
- /**
- * Some "getter" for a linked list of all categories
- * <p>
- * @return All categories
- * <p>
- * @throws javax.faces.view.facelets.FaceletException If anything went wrong
- * @todo Move this to own controller
- */
- List<Category> getAllCategories () throws FaceletException;
-
- /**
- * Some "getter" for a linked list of all categories including "Has no
- * parent" fake category.
- * <p>
- * @return All categories
- * <p>
- * @throws javax.faces.view.facelets.FaceletException If anything went wrong
- * @todo Move this to own controller
- */
- List<Category> getAllCategoriesParent () throws FaceletException;
-
- /**
- * Some "getter" for a linked list of only available products
- * <p>
- * @return Only available products
- * <p>
- * @throws javax.faces.view.facelets.FaceletException If anything went wrong
- */
- List<Product> getAvailableProducts () throws FaceletException;
-
- /**
- * Observes events fired after a new product category has been added
- * <p>
- * @param event Event to be observed
- * @todo Move this to own controller
- */
- void afterShopCategoryAdded (final AddedCategoryEvent event);
-
- /**
- * Observes events fired after a new product has been added
- * <p>
- * @param event Event to be observed
- * @todo Move this to own controller
- */
- void afterShopProductAdded (final AddedProductEvent event);
-
-}
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:selectOneMenu class="select" id="product_category" value="#{adminProductController.productCategory}" required="true" requiredMessage="#{msg.ADMIN_CATEGORY_MUST_BE_SELECTED}" converter="CategoryConverter">
- <f:selectItems value="#{shopController.allCategories}" var="cat" itemValue="#{cat}" itemLabel="#{cat.categoryTitle}" />
+ <f:selectItems value="#{categoryController.allCategories}" var="cat" itemValue="#{cat}" itemLabel="#{cat.categoryTitle}" />
</h:selectOneMenu>
</ui:composition>
<h:selectOneMenu class="select" id="parentCategory" value="#{adminCategoryController.parentCategory}">
<f:selectItem itemValue="" itemLabel="#{msg.ADMIN_CATEGORY_HAS_NO_PARENT}" />
- <f:selectItems value="#{shopController.allCategoriesParent}" var="parent_category" itemValue="#{parent_category.categoryId}" itemLabel="#{parent_category.categoryTitle}" />
+ <f:selectItems value="#{categoryController.allCategoriesParent}" var="parent_category" itemValue="#{parent_category.categoryId}" itemLabel="#{parent_category.categoryTitle}" />
</h:selectOneMenu>
</ui:composition>
<ui:define name="content">
<div class="para">
- <h:dataTable id="categories" var="cat" value="#{shopController.allCategories}" styleClass="table" headerClass="table_header_column" summary="#{msg.TABLE_SUMMARY_ADMIN_CATEGORY}">
+ <h:dataTable id="categories" var="cat" value="#{categoryController.allCategories}" styleClass="table" headerClass="table_header_column" summary="#{msg.TABLE_SUMMARY_ADMIN_CATEGORY}">
<h:column>
<f:facet name="header">#{msg.ADMIN_CATEGORY_ID}</f:facet>
<h:link outcome="admin_edit_category" title="#{msg.ADMIN_LINK_EDIT_DELETE_CATEGORY_TITLE}" value="#{cat.categoryId}">
</div>
</div>
- <h:dataTable id="table_show_available_products" var="product" value="#{shopController.availableProducts}" styleClass="table" summary="#{msg.TABLE_SUMMARY_INDEX_PRODUCTS}">
+ <h:dataTable id="table_show_available_products" var="product" value="#{productController.availableProducts}" styleClass="table" summary="#{msg.TABLE_SUMMARY_INDEX_PRODUCTS}">
<h:column>
<div id="main_item_container">
<div class="item_title">