*/
package org.mxchange.pizzaapplication.category;
+import java.io.UnsupportedEncodingException;
import java.text.MessageFormat;
import java.util.Objects;
import org.mxchange.jcore.BaseFrameworkSystem;
public final void setTitle (final String title) {
this.title = title;
}
+
+ /**
+ * Decodes the UTF8-encoded title
+ *
+ * @return Decoded title
+ */
+ @Override
+ public final String decodedTitle () throws UnsupportedEncodingException {
+ // Get title
+ byte[] t = this.getTitle().getBytes();
+
+ // Decode it
+ return new String(t, "UTF-8");
+ }
}
*/
package org.mxchange.pizzaapplication.category;
+import java.io.UnsupportedEncodingException;
import org.mxchange.jcore.database.storage.Storeable;
/**
*/
@Override
public int compareTo (final Category category);
+
+ /**
+ * Decodes the UTF8-encoded title
+ *
+ * @return Decoded title
+ * @throws java.io.UnsupportedEncodingException If the encoding UTF-8 is not supported
+ */
+ public String decodedTitle () throws UnsupportedEncodingException ;
}
--- /dev/null
+/*
+ * 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.exceptions;
+
+import java.text.MessageFormat;
+import javax.servlet.http.HttpServletRequest;
+import org.mxchange.pizzaapplication.database.category.PizzaCategoryDatabaseConstants;
+
+/**
+ * An exception thrown when the given title is already used
+ *
+ * @author Roland Haeder
+ */
+public class CategoryTitleAlreadyUsedException extends Exception {
+
+ /**
+ * Constructor with HttpServletRequest instance
+ *
+ * @param request A HttpServletRequest instance
+ */
+ public CategoryTitleAlreadyUsedException (final HttpServletRequest request) {
+ // Call super constructor
+ super(MessageFormat.format("Title {0} is already used.", request.getParameter(PizzaCategoryDatabaseConstants.COLUMN_TITLE)));
+ }
+
+}
<input type="checkbox" name="<%=PizzaCategoryDatabaseConstants.COLUMN_ID%>[${category.getId()}]" value="1" />
</td>
<td>
- ${category.getTitle()}
+ ${category.decodedTitle()}
</td>
<td>
${app.generateLinkForParent(category)}
<div class="clear"></div>
</div>
+
+ <div class="data_row">
+ <div class="table_left">
+ Kategorie:
+ </div>
+
+ <div class="table_right">
+ <jsp:include flush="true" page="/static/admin/category_selection_box.jsp" />
+ </div>
+
+ <div class="clear"></div>
+ </div>
</fieldset>
<div class="table_footer">
--- /dev/null
+<%--
+ Document : parent_category_selection_box
+ Created on : 14.08.2015, 12:51:05
+ Author : Roland Haeder
+--%>
+
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+<%@page import="org.mxchange.pizzaapplication.database.category.PizzaCategoryDatabaseConstants"%>
+<%@page import="org.mxchange.pizzaapplication.application.PizzaServiceApplication"%>
+<%@page import="org.mxchange.pizzaapplication.application.PizzaApplication"%>
+
+<%
+ // Init application instance
+ PizzaApplication app = PizzaServiceApplication.getInstance(application);
+%>
+
+<select name="<%=PizzaCategoryDatabaseConstants.COLUMN_ID%>" size="1">
+ <c:forEach var="category" items="<%=app.getCategories()%>">
+ <option value="${category.getId()}">${category.decodedTitle()}</option>
+ </c:forEach>
+</select>
Author : Roland Haeder
--%>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page import="org.mxchange.pizzaapplication.database.category.PizzaCategoryDatabaseConstants"%>
+<%@page import="org.mxchange.pizzaapplication.application.PizzaServiceApplication"%>
+<%@page import="org.mxchange.pizzaapplication.application.PizzaApplication"%>
+
+<%
+ // Init application instance
+ PizzaApplication app = PizzaServiceApplication.getInstance(application);
+%>
<select name="<%=PizzaCategoryDatabaseConstants.COLUMN_PARENT%>" size="1">
<option value="">Ist oberste Kategorie</option>
+ <c:forEach var="category" items="<%=app.getCategories()%>">
+ <option value="${category.getId()}">${category.decodedTitle()}</option>
+ </c:forEach>
</select>