From 132833660be5b95dfb8a2ef9adda79dcd94282da Mon Sep 17 00:00:00 2001
From: =?utf8?q?Roland=20H=C3=A4der?= <roland@mxchange.org>
Date: Fri, 17 Apr 2020 16:58:31 +0200
Subject: [PATCH] Product-only: - heavy rewrite on (almost?) all admin-list-foo
 views, to use @ViewScoped beans   and working JSR107 caching - also sorted
 out mixed usage of userController (or so?) as the login and   register
 backing beans can surely have their own properties - rewrote
 web/WEB-INF/resources/tags/admin/dropdown/ to have it included back   in
 views again, was a bad idea
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit

Signed-off-by: Roland Häder <roland@mxchange.org>
---
 .../FinancialsProductListWebViewBean.java     |  2 +-
 .../FinancialsCategoryListWebViewBean.java    |  2 +-
 web/WEB-INF/product-links.jsf.taglib.xml      | 46 -------------------
 .../admin_generic_product_links.tpl           | 37 ---------------
 .../admin_product_category_links.tpl          | 37 ---------------
 .../admin_generic_product_list.xhtml          | 27 ++++++++++-
 .../admin_product_category_list.xhtml         | 27 ++++++++++-
 7 files changed, 54 insertions(+), 124 deletions(-)
 delete mode 100644 web/WEB-INF/resources/tags/admin/dropdown/generic_product/admin_generic_product_links.tpl
 delete mode 100644 web/WEB-INF/resources/tags/admin/dropdown/product_category/admin_product_category_links.tpl

diff --git a/src/java/org/mxchange/jfinancials/beans/generic_product/list/FinancialsProductListWebViewBean.java b/src/java/org/mxchange/jfinancials/beans/generic_product/list/FinancialsProductListWebViewBean.java
index 363bad42..45fbd855 100644
--- a/src/java/org/mxchange/jfinancials/beans/generic_product/list/FinancialsProductListWebViewBean.java
+++ b/src/java/org/mxchange/jfinancials/beans/generic_product/list/FinancialsProductListWebViewBean.java
@@ -217,7 +217,7 @@ public class FinancialsProductListWebViewBean extends BaseFinancialsBean impleme
 		// Is cache there?
 		if (!this.productCache.iterator().hasNext()) {
 			// "Walk" through all entries and add to cache
-			for (final Product product : this.productBean.allProducts()) {
+			for (final Product product : this.productBean.fetchAllProducts()) {
 				// Add it by primary key
 				this.productCache.put(product.getProductId(), product);
 			}
diff --git a/src/java/org/mxchange/jfinancials/beans/product_category/list/FinancialsCategoryListWebViewBean.java b/src/java/org/mxchange/jfinancials/beans/product_category/list/FinancialsCategoryListWebViewBean.java
index 9b2b22a8..bd850fc3 100644
--- a/src/java/org/mxchange/jfinancials/beans/product_category/list/FinancialsCategoryListWebViewBean.java
+++ b/src/java/org/mxchange/jfinancials/beans/product_category/list/FinancialsCategoryListWebViewBean.java
@@ -192,7 +192,7 @@ public class FinancialsCategoryListWebViewBean extends BaseFinancialsBean implem
 		// Is cache there?
 		if (!this.categoryCache.iterator().hasNext()) {
 			// "Walk" through all entries and add to cache
-			for (final Category category : this.categoryBean.allCategories()) {
+			for (final Category category : this.categoryBean.fetchAllCategories()) {
 				// Add it by primary key
 				this.categoryCache.put(category.getCategoryId(), category);
 			}
diff --git a/web/WEB-INF/product-links.jsf.taglib.xml b/web/WEB-INF/product-links.jsf.taglib.xml
index 711698d9..49556a1e 100644
--- a/web/WEB-INF/product-links.jsf.taglib.xml
+++ b/web/WEB-INF/product-links.jsf.taglib.xml
@@ -22,50 +22,4 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 	xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facelettaglibrary_2_2.xsd"
 >
 	<namespace>http://mxchange.org/jsf/jproduct/links</namespace>
-	<tag>
-		<tag-name>outputProductCategoryAdminDropdownMenu</tag-name>
-		<description>This tag renders an administrative drop-down menu for given category instance.</description>
-		<source>resources/tags/admin/dropdown/product_category/admin_product_category_links.tpl</source>
-		<attribute>
-			<name>category</name>
-			<description>The product category instance that provides the data for this tag.</description>
-			<required>true</required>
-			<type>org.mxchange.jproduct.model.category.Category</type>
-		</attribute>
-		<attribute>
-			<name>renderShowLink</name>
-			<description>Whether to render (default: true) "show product" link.</description>
-			<required>false</required>
-			<type>java.langBoolean</type>
-		</attribute>
-		<attribute>
-			<name>rendered</name>
-			<description>Whether this tag is being rendered by JSF engine (default: true).</description>
-			<required>false</required>
-			<type>java.lang.Boolean</type>
-		</attribute>
-	</tag>
-	<tag>
-		<tag-name>outputGenericProductAdminDropdownMenu</tag-name>
-		<description>This tag renders an administrative drop-down menu for given product instance.</description>
-		<source>resources/tags/admin/dropdown/generic_product/admin_generic_product_links.tpl</source>
-		<attribute>
-			<name>genericProduct</name>
-			<description>The generic product instance that provides the data for this tag.</description>
-			<required>true</required>
-			<type>org.mxchange.jproduct.model.product.Product</type>
-		</attribute>
-		<attribute>
-			<name>renderShowLink</name>
-			<description>Whether to render (default: true) "show product" link.</description>
-			<required>false</required>
-			<type>java.langBoolean</type>
-		</attribute>
-		<attribute>
-			<name>rendered</name>
-			<description>Whether this tag is being rendered by JSF engine (default: true).</description>
-			<required>false</required>
-			<type>java.lang.Boolean</type>
-		</attribute>
-	</tag>
 </facelet-taglib>
diff --git a/web/WEB-INF/resources/tags/admin/dropdown/generic_product/admin_generic_product_links.tpl b/web/WEB-INF/resources/tags/admin/dropdown/generic_product/admin_generic_product_links.tpl
deleted file mode 100644
index 7b1ede12..00000000
--- a/web/WEB-INF/resources/tags/admin/dropdown/generic_product/admin_generic_product_links.tpl
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<ui:composition
-	xmlns="http://www.w3.org/1999/xhtml"
-	xmlns:f="http://java.sun.com/jsf/core"
-	xmlns:h="http://java.sun.com/jsf/html"
-	xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
-	xmlns:p="http://primefaces.org/ui"
-	>
-
-	<p:menuButton value="#{msg.OPTIONS}" rendered="#{empty rendered or rendered}">
-		<p:menuitem
-			outcome="admin_show_generic_product"
-			value="#{msg.ADMIN_LINK_SHOW_SHORT}"
-			title="#{product.ADMIN_LINK_SHOW_GENERIC_PRODUCT_TITLE}"
-			rendered="#{empty renderShowLink or renderShowLink}"
-			>
-			<f:param name="productId" value="#{genericProduct.productId}" />
-		</p:menuitem>
-
-		<p:menuitem
-			outcome="admin_edit_generic_product"
-			value="#{msg.ADMIN_LINK_EDIT_SHORT}"
-			title="#{product.ADMIN_LINK_EDIT_GENERIC_PRODUCT_TITLE}"
-			>
-			<f:param name="productId" value="#{genericProduct.productId}" />
-		</p:menuitem>
-
-		<p:menuitem outcome="admin_delete_generic_product">
-			<h:outputText
-				styleClass="link-danger"
-				value="#{msg.ADMIN_LINK_DELETE_SHORT}"
-				title="#{product.ADMIN_LINK_DELETE_GENERIC_PRODUCT_TITLE}"
-				/>
-			<f:param name="productId" value="#{genericProduct.productId}" />
-		</p:menuitem>
-	</p:menuButton>
-</ui:composition>
diff --git a/web/WEB-INF/resources/tags/admin/dropdown/product_category/admin_product_category_links.tpl b/web/WEB-INF/resources/tags/admin/dropdown/product_category/admin_product_category_links.tpl
deleted file mode 100644
index 182bab72..00000000
--- a/web/WEB-INF/resources/tags/admin/dropdown/product_category/admin_product_category_links.tpl
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<ui:composition
-	xmlns="http://www.w3.org/1999/xhtml"
-	xmlns:f="http://java.sun.com/jsf/core"
-	xmlns:h="http://java.sun.com/jsf/html"
-	xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
-	xmlns:p="http://primefaces.org/ui"
-	>
-
-	<p:menuButton value="#{msg.OPTIONS}" rendered="#{empty rendered or rendered}">
-		<p:menuitem
-			outcome="admin_show_product_category"
-			value="#{msg.ADMIN_LINK_SHOW_SHORT}"
-			title="#{product.ADMIN_LINK_SHOW_PRODUCT_CATEGORY_TITLE}"
-			rendered="#{empty renderShowLink or renderShowLink}"
-			>
-			<f:param name="categoryId" value="#{category.categoryId}" />
-		</p:menuitem>
-
-		<p:menuitem
-			outcome="admin_edit_product_category"
-			value="#{msg.ADMIN_LINK_EDIT_SHORT}"
-			title="#{product.ADMIN_LINK_EDIT_PRODUCT_CATEGORY_TITLE}"
-			>
-			<f:param name="categoryId" value="#{category.categoryId}" />
-		</p:menuitem>
-
-		<p:menuitem outcome="admin_delete_product_category">
-			<h:outputText
-				styleClass="link-danger"
-				value="#{msg.ADMIN_LINK_DELETE_SHORT}"
-				title="#{product.ADMIN_LINK_DELETE_PRODUCT_CATEGORY_TITLE}"
-				/>
-			<f:param name="categoryId" value="#{category.categoryId}" />
-		</p:menuitem>
-	</p:menuButton>
-</ui:composition>
diff --git a/web/admin/generic_product/admin_generic_product_list.xhtml b/web/admin/generic_product/admin_generic_product_list.xhtml
index bdbd0013..4f6c290f 100644
--- a/web/admin/generic_product/admin_generic_product_list.xhtml
+++ b/web/admin/generic_product/admin_generic_product_list.xhtml
@@ -253,7 +253,32 @@
 					sortable="false"
 					filterable="false"
 					>
-					<product-links:outputGenericProductAdminDropdownMenu genericProduct="#{genericProduct}" />
+					<p:menuButton value="#{msg.OPTIONS}">
+						<p:menuitem
+							outcome="admin_show_generic_product"
+							value="#{msg.ADMIN_LINK_SHOW_SHORT}"
+							title="#{product.ADMIN_LINK_SHOW_GENERIC_PRODUCT_TITLE}"
+							>
+							<f:param name="productId" value="#{genericProduct.productId}" />
+						</p:menuitem>
+
+						<p:menuitem
+							outcome="admin_edit_generic_product"
+							value="#{msg.ADMIN_LINK_EDIT_SHORT}"
+							title="#{product.ADMIN_LINK_EDIT_GENERIC_PRODUCT_TITLE}"
+							>
+							<f:param name="productId" value="#{genericProduct.productId}" />
+						</p:menuitem>
+
+						<p:menuitem outcome="admin_delete_generic_product">
+							<h:outputText
+								styleClass="link-danger"
+								value="#{msg.ADMIN_LINK_DELETE_SHORT}"
+								title="#{product.ADMIN_LINK_DELETE_GENERIC_PRODUCT_TITLE}"
+								/>
+							<f:param name="productId" value="#{genericProduct.productId}" />
+						</p:menuitem>
+					</p:menuButton>
 				</p:column>
 			</p:dataTable>
 
diff --git a/web/admin/product_category/admin_product_category_list.xhtml b/web/admin/product_category/admin_product_category_list.xhtml
index 8e0c0dc9..ee96d9f2 100644
--- a/web/admin/product_category/admin_product_category_list.xhtml
+++ b/web/admin/product_category/admin_product_category_list.xhtml
@@ -171,7 +171,32 @@
 					sortable="false"
 					filterable="false"
 					>
-					<product-links:outputProductCategoryAdminDropdownMenu category="#{category}" />
+					<p:menuButton value="#{msg.OPTIONS}">
+						<p:menuitem
+							outcome="admin_show_product_category"
+							value="#{msg.ADMIN_LINK_SHOW_SHORT}"
+							title="#{product.ADMIN_LINK_SHOW_PRODUCT_CATEGORY_TITLE}"
+							>
+							<f:param name="categoryId" value="#{category.categoryId}" />
+						</p:menuitem>
+
+						<p:menuitem
+							outcome="admin_edit_product_category"
+							value="#{msg.ADMIN_LINK_EDIT_SHORT}"
+							title="#{product.ADMIN_LINK_EDIT_PRODUCT_CATEGORY_TITLE}"
+							>
+							<f:param name="categoryId" value="#{category.categoryId}" />
+						</p:menuitem>
+
+						<p:menuitem outcome="admin_delete_product_category">
+							<h:outputText
+								styleClass="link-danger"
+								value="#{msg.ADMIN_LINK_DELETE_SHORT}"
+								title="#{product.ADMIN_LINK_DELETE_PRODUCT_CATEGORY_TITLE}"
+								/>
+							<f:param name="categoryId" value="#{category.categoryId}" />
+						</p:menuitem>
+					</p:menuButton>
 				</p:column>
 			</p:dataTable>
 
-- 
2.39.5