--- /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.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<Gender> getSelectableGenders ();
+}
--- /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.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<Gender> getSelectableGenders () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
+ // Init array
+ List<Gender> 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;
+ }
+}
<validator-id>PrivacyTermsCheckboxValidator</validator-id>
<validator-class>org.mxchange.jsfcore.validator.bool.privacy_terms.PrivacyTermsCheckboxValidator</validator-class>
</validator>
+ <validator>
+ <validator-id>NameValidator</validator-id>
+ <validator-class>org.mxchange.jsfcore.validator.string.names.NameValidator</validator-class>
+ </validator>
</faces-config>
-<?xml version='1.0' encoding='UTF-8' ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<?xml version="1.0" encoding="UTF-8" ?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
- xmlns:ui="http://java.sun.com/jsf/facelets">
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <f:loadBundle var="msg" basename="org.mxchange.localization.bundle" />
<h:outputStylesheet name="./css/default.css"/>
<h:outputStylesheet name="./css/cssLayout.css"/>
<title>Pizza-Service - <ui:insert name="title">Default title</ui:insert></title>
<!--
TODO: Missing pre-select of choosen gender
//-->
- <h:selectOneListbox class="select" id="gender" size="1">
- <ui:repeat var="gender" value="#{Gender.values()}">
- <option value="#{gender.name()}">#{gender}</option>
- </ui:repeat>
- </h:selectOneListbox>
+ <h:selectOneMenu class="select" id="gender" value="#{customer.gender}">
+ <f:selectItems value="#{data.selectableGenders}" var="gender" itemValue="#{gender}" itemLabel="#{msg[gender.messageKey]}" />
+ </h:selectOneMenu>
</ui:composition>
-<?xml version='1.0' encoding='UTF-8' ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<?xml version="1.0" encoding="UTF-8" ?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
-<?xml version='1.0' encoding='UTF-8' ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<?xml version="1.0" encoding="UTF-8" ?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
-<?xml version='1.0' encoding='UTF-8' ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<?xml version="1.0" encoding="UTF-8" ?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
</div>
<div class="table_right">
- <c:set var="enabled" scope="request" value="true" />
<ui:include src="/WEB-INF/templates/generic/gender_selection_box.tpl" />
</div>
</div>
<div class="table_right">
- <h:inputText class="input" id="firstName" size="10" maxlength="255" value="#{customer.firstName}" required="true" />
+ <h:inputText class="input" id="firstName" size="10" maxlength="255" value="#{customer.firstName}" required="true">
+ <f:validator validatorId="NameValidator" />
+ </h:inputText>
</div>
<div class="clear"></div>
</div>
<div class="table_right">
- <h:inputText class="input" id="familyName" size="10" maxlength="255" value="#{customer.familyName}" required="true" />
+ <h:inputText class="input" id="familyName" size="10" maxlength="255" value="#{customer.familyName}" required="true">
+ <f:validator validatorId="NameValidator" />
+ </h:inputText>
</div>
<div class="clear"></div>
</div>
<div class="table_right">
- <h:inputText class="input" id="street" size="20" maxlength="255" value="#{customer.street}" required="true" />
+ <h:inputText class="input" id="street" size="20" maxlength="255" value="#{customer.street}" required="true">
+ <f:validator validatorId="NameValidator" />
+ </h:inputText>
</div>
<div class="clear"></div>
</div>
<div class="table_right">
- <h:inputText class="input" id="houseNumber" size="3" maxlength="5" value="#{customer.houseNumber}" required="true" />
+ <h:inputText class="input" id="houseNumber" size="3" maxlength="5" value="#{customer.houseNumber}" required="true">
+ <f:validateLongRange minimum="1" maximum="500" />
+ </h:inputText>
</div>
<div class="clear"></div>
</div>
<div class="table_right">
- <h:inputText class="input" id="city" size="10" maxlength="255" value="#{customer.city}" required="true" />
+ <h:inputText class="input" id="city" size="10" maxlength="255" value="#{customer.city}" required="true">
+ <f:validator validatorId="NameValidator" />
+ </h:inputText>
</div>
<div class="clear"></div>
-<?xml version='1.0' encoding='UTF-8' ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<?xml version="1.0" encoding="UTF-8" ?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
-<?xml version='1.0' encoding='UTF-8' ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<?xml version="1.0" encoding="UTF-8" ?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
-<?xml version='1.0' encoding='UTF-8' ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<?xml version="1.0" encoding="UTF-8" ?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
-<?xml version='1.0' encoding='UTF-8' ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<?xml version="1.0" encoding="UTF-8" ?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"