From: Roland Haeder Date: Sun, 6 Sep 2015 08:25:39 +0000 (+0200) Subject: No tags in EJBs, maybe not JSF, too? X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=34ab8551aa582cc6099145d4e77ae3ce63ba794c;p=pizzaservice-ejb.git No tags in EJBs, maybe not JSF, too? Signed-off-by:Roland Häder --- diff --git a/PizzaService-ejb/src/java/org/mxchange/pizzaapplication/tags/basket/BasketTag.java b/PizzaService-ejb/src/java/org/mxchange/pizzaapplication/tags/basket/BasketTag.java deleted file mode 100644 index 5e8ae1b..0000000 --- a/PizzaService-ejb/src/java/org/mxchange/pizzaapplication/tags/basket/BasketTag.java +++ /dev/null @@ -1,27 +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.tags.basket; - -import javax.servlet.jsp.tagext.BodyTag; - -/** - * An interface for a (mini) basket tag. - * - * @author Roland Haeder - */ -public interface BasketTag extends BodyTag { -} diff --git a/PizzaService-ejb/src/java/org/mxchange/pizzaapplication/tags/basket/MiniBasketTag.java b/PizzaService-ejb/src/java/org/mxchange/pizzaapplication/tags/basket/MiniBasketTag.java deleted file mode 100644 index 3dfe70a..0000000 --- a/PizzaService-ejb/src/java/org/mxchange/pizzaapplication/tags/basket/MiniBasketTag.java +++ /dev/null @@ -1,154 +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.tags.basket; - -import java.io.IOException; -import java.rmi.RemoteException; -import java.text.MessageFormat; -import javax.servlet.jsp.JspException; -import javax.servlet.jsp.tagext.BodyTagSupport; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.mxchange.jshopcore.model.item.AddableBasketItem; -import org.mxchange.jshopcore.model.product.Product; -import org.mxchange.jshopejb.beans.remote.shop.ShopSessionBeanRemote; - -/** - * A basket tag that outputs a small basket and a link to the full basket website. - * - * @author Roland Haeder - * TODO: Does JSF use "foreign" tags like this? - */ -public class MiniBasketTag extends BodyTagSupport implements BasketTag { - /** - * Serial number - */ - private static final long serialVersionUID = 457415727452384L; - - /** - * Logger instance - */ - private final Logger LOG; - - /** - * Initializer - */ - { - this.LOG = LogManager.getLogger(this); - } - - /** - * Outputs a div container with last added item + a link to the basket - * web page. - * - * @return No need to process the body - * @throws JspException If anything happens - */ - @Override - public int doStartTag () throws JspException { - // Trace message - this.LOG.trace("CALLED!"); //NOI18N - - // Init output - StringBuilder out = new StringBuilder("
\n"); //NOI18N - - // basket should not be null - if (this.getBasket() == null) { - // Not set - throw new NullPointerException("basket instance is null"); //NOI18N - } - - try { - // Some entries found? - if (this.getBasket().isEmpty()) { - // Empty basket - out.append("
\n"); //NOI18N - out.append(this.getBasket().getMessageStringFromKey("MiniBasketTag.basket_is_empty")).append("\n"); //NOI18N - out.append("
\n"); //NOI18N - } else { - // Get all items - AddableBasketItem item = this.getBasket().getLast(); - - // item cannot be null here - if (null == item) { - // Abort here - throw new NullPointerException("item is null"); //NOI18N - } - - // Get application bean from session - ShopSessionBeanRemote bean = (ShopSessionBeanRemote) this.getBasket().getSession().getAttribute("controller"); //NOI18N - - // Debug log - this.LOG.debug(MessageFormat.format("bean={0}", bean)); //NOI18N - - // Should not be null - if (null == bean) { - // Abort here - throw new NullPointerException("bean is null"); //NOI18N - } - - // Get product instance - Product product = bean.getProduct(item); - - // Debug message - this.LOG.debug(MessageFormat.format("product={0}", product)); //NOI18N - - // Get last num rows - int lastNumRows = this.getBasket().getLastNumRows(); - - // Debug message - this.LOG.debug(MessageFormat.format("lastNumRows={0}", lastNumRows)); //NOI18N - - // Output all - out.append("
\n"); //NOI18N - out.append("
\n"); //NOI18N - out.append(" ").append(this.getBasket().getMessageStringFromKey("MiniBasketTag.header")).append("\n"); //NOI18N - out.append("
\n"); //NOI18N - out.append("
\n"); //NOI18N - out.append(" ").append(MessageFormat.format(this.getBasket().getMessageStringFromKey("MiniBasketTag.last_item"), product.getTitle())); //NOI18N - out.append("
\n"); //NOI18N - out.append("
\n"); //NOI18N - out.append(" ").append(MessageFormat.format(this.getBasket().getMessageStringFromKey("MiniBasketTag.additional_items"), (lastNumRows - 1))); //NOI18N - out.append("
\n"); //NOI18N - out.append("
\n"); //NOI18N - out.append(" ").append(this.getBasket().getMessageStringFromKey("MiniBasketTag.to_basket")).append("\n"); //NOI18N - out.append("
\n"); //NOI18N - out.append("
\n"); //NOI18N - } - } catch (final RemoteException ex) { - // Continue to throw - throw new JspException(ex); - } - - // Close div here - out.append("
\n"); //NOI18N - - try { - // Get output instance and write it - this.pageContext.getOut().print(out.toString()); - } catch (final IOException ex) { - // Continue to throw - throw new JspException(ex); - } - - // Trace message - this.LOG.trace(MessageFormat.format("Returning {0} ... - EXIT!", SKIP_BODY)); //NOI18N - - // Don't process any body - return SKIP_BODY; - } -}