From: Roland Haeder Date: Thu, 3 Sep 2015 13:33:34 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=cddf98113209fac56d0c7859901708fd6773ccd4;p=pizzaservice-war.git Continued: - added DataBean which will hold "static" data, e.g. genders - continued with improvements Signed-off-by:Roland Häder --- diff --git a/lib/jcore.jar b/lib/jcore.jar index 526b59ec..74d0330e 100644 Binary files a/lib/jcore.jar and b/lib/jcore.jar differ diff --git a/lib/jsfcore.jar b/lib/jsfcore.jar index e49e7da8..80348e4c 100644 Binary files a/lib/jsfcore.jar and b/lib/jsfcore.jar differ diff --git a/src/java/org/mxchange/pizzaapplication/beans/enums/DataBean.java b/src/java/org/mxchange/pizzaapplication/beans/enums/DataBean.java new file mode 100644 index 00000000..6a7d4000 --- /dev/null +++ b/src/java/org/mxchange/pizzaapplication/beans/enums/DataBean.java @@ -0,0 +1,41 @@ +/* + * 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.beans.enums; + +import java.util.List; +import org.mxchange.jcore.contact.Gender; +import org.mxchange.jshop.beans.FrameworkBean; + +/** + * An interface for data beans + * + * @author Roland Haeder + */ +public interface DataBean extends FrameworkBean { + /** + * Getter for all genders as array + * + * @return All genders as array + */ + public Gender[] getGenders (); + /** + * Getter for only selectable genders as array, UNKNOWN is not selectable + * + * @return All genders as array + */ + public List getSelectableGenders (); +} diff --git a/src/java/org/mxchange/pizzaapplication/beans/enums/PizzaServiceDataBean.java b/src/java/org/mxchange/pizzaapplication/beans/enums/PizzaServiceDataBean.java new file mode 100644 index 00000000..152f60bd --- /dev/null +++ b/src/java/org/mxchange/pizzaapplication/beans/enums/PizzaServiceDataBean.java @@ -0,0 +1,86 @@ +/* + * 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.beans.enums; + +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Named; +import org.mxchange.jcore.contact.Gender; +import org.mxchange.jshop.beans.BaseFrameworkBean; + +/** + * A customer bean which hides the customer instance + * + * @author Roland Haeder + */ +@Named ("data") +@ApplicationScoped +public class PizzaServiceDataBean extends BaseFrameworkBean implements DataBean { + + /** + * Serial number + */ + private static final long serialVersionUID = 835482364189L; + + @Override + public Gender[] getGenders () { + // Trace message + this.getLogger().trace(MessageFormat.format("Genders={0} - EXIT!", Arrays.toString(Gender.values()))); + + // Return it + return Gender.values(); + } + + @Override + public List getSelectableGenders () { + // Trace message + this.getLogger().trace("CALLED!"); //NOI18N + + // Init array + List genders = new ArrayList<>(this.getGenders().length - 1); + + // Debug message + this.getLogger().debug(MessageFormat.format("genders.size()={0}", genders.size())); + + // Return it + for (final Gender gender : Gender.values()) { + // Debug message + this.getLogger().debug(MessageFormat.format("gender={0}", gender)); + + // Is it unknown? + if (!gender.equals(Gender.UNKNOWN)) { + // Debug message + this.getLogger().debug(MessageFormat.format("gender={0} - adding ...", gender)); + + // Not, then add it + boolean added = genders.add(gender); + + // Debug message + this.getLogger().debug(MessageFormat.format("added={0}", added)); + } + } + + // Trace message + this.getLogger().trace(MessageFormat.format("genders={0} - EXIT!", genders)); //NOI18N + + // Return it + return genders; + } +} diff --git a/web/WEB-INF/faces-config.xml b/web/WEB-INF/faces-config.xml index d7b1bde5..59dad757 100644 --- a/web/WEB-INF/faces-config.xml +++ b/web/WEB-INF/faces-config.xml @@ -7,4 +7,8 @@ PrivacyTermsCheckboxValidator org.mxchange.jsfcore.validator.bool.privacy_terms.PrivacyTermsCheckboxValidator + + NameValidator + org.mxchange.jsfcore.validator.string.names.NameValidator + diff --git a/web/WEB-INF/templates.dist/guest_page.xhtml b/web/WEB-INF/templates.dist/guest_page.xhtml index d045118d..7439d638 100644 --- a/web/WEB-INF/templates.dist/guest_page.xhtml +++ b/web/WEB-INF/templates.dist/guest_page.xhtml @@ -1,5 +1,4 @@ - - + - + xmlns:ui="http://java.sun.com/jsf/facelets" + xmlns:f="http://xmlns.jcp.org/jsf/core"> + Pizza-Service - <ui:insert name="title">Default title</ui:insert> diff --git a/web/WEB-INF/templates/generic/gender_selection_box.tpl b/web/WEB-INF/templates/generic/gender_selection_box.tpl index 18b0d360..7360554e 100644 --- a/web/WEB-INF/templates/generic/gender_selection_box.tpl +++ b/web/WEB-INF/templates/generic/gender_selection_box.tpl @@ -7,9 +7,7 @@ - - - - - + + + diff --git a/web/customer/login.xhtml b/web/customer/login.xhtml index ab2c954d..198e37cb 100644 --- a/web/customer/login.xhtml +++ b/web/customer/login.xhtml @@ -1,5 +1,4 @@ - - + - + - +
-
@@ -68,7 +66,9 @@
- + + +
@@ -80,7 +80,9 @@
- + + +
@@ -92,7 +94,9 @@
- + + +
@@ -104,7 +108,9 @@
- + + +
@@ -128,7 +134,9 @@
- + + +
diff --git a/web/imprint.xhtml b/web/imprint.xhtml index f7512adf..f31594d2 100644 --- a/web/imprint.xhtml +++ b/web/imprint.xhtml @@ -1,5 +1,4 @@ - - + - + - + - +