From: Roland Haeder Date: Sat, 5 Sep 2015 13:03:15 +0000 (+0200) Subject: Renaming season is not yet over ... ;-) X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a53a324e453d154ccefbbb4b8dc3290c78a28cce;p=jcoreee.git Renaming season is not yet over ... ;-) Signed-off-by:Roland Häder --- diff --git a/build.xml b/build.xml index 0316294..6c4e6fe 100644 --- a/build.xml +++ b/build.xml @@ -7,8 +7,8 @@ - - Builds, tests, and runs the project jcore-ejb. + + Builds, tests, and runs the project jcoreee. - + @@ -468,7 +468,7 @@ is divided into following sections: - + @@ -619,7 +619,7 @@ is divided into following sections: - + @@ -911,7 +911,7 @@ is divided into following sections: - + @@ -1396,7 +1396,7 @@ is divided into following sections: - + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties index 4ba34ae..622716b 100644 --- a/nbproject/genfiles.properties +++ b/nbproject/genfiles.properties @@ -1,8 +1,8 @@ -build.xml.data.CRC32=3641d4bf -build.xml.script.CRC32=fb3c526a +build.xml.data.CRC32=4032bd34 +build.xml.script.CRC32=3357aa22 build.xml.stylesheet.CRC32=8064a381@1.75.2.48 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=3641d4bf -nbproject/build-impl.xml.script.CRC32=93112dc4 +nbproject/build-impl.xml.data.CRC32=4032bd34 +nbproject/build-impl.xml.script.CRC32=29041c33 nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48 diff --git a/nbproject/project.properties b/nbproject/project.properties index 6982d96..797dd3a 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -3,7 +3,7 @@ annotation.processing.enabled.in.editor=true annotation.processing.processors.list= annotation.processing.run.all.processors=true annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output -application.title=jcore-ejb +application.title=jcoreee application.vendor=Roland Haeder auxiliary.org-netbeans-spi-editor-hints-projects.perProjectHintSettingsFile=nbproject/cfg_hints.xml build.classes.dir=${build.dir}/classes @@ -26,7 +26,7 @@ debug.test.classpath=\ dist.archive.excludes= # This directory is removed when the project is cleaned: dist.dir=dist -dist.jar=${dist.dir}/jcore-ejb.jar +dist.jar=${dist.dir}/jcoreee.jar dist.javadoc.dir=${dist.dir}/javadoc endorsed.classpath= excludes= diff --git a/nbproject/project.xml b/nbproject/project.xml index 473995e..386475b 100644 --- a/nbproject/project.xml +++ b/nbproject/project.xml @@ -3,7 +3,7 @@ org.netbeans.modules.java.j2seproject - jcore-ejb + jcoreee diff --git a/src/org/mxchange/jcoreee/BaseServletSystem.java b/src/org/mxchange/jcoreee/BaseServletSystem.java new file mode 100644 index 0000000..10ce7b6 --- /dev/null +++ b/src/org/mxchange/jcoreee/BaseServletSystem.java @@ -0,0 +1,26 @@ +/* + * 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.jcoreee; + +import org.mxchange.jcore.BaseFrameworkSystem; + +/** + * A general shop class + * @author Roland Haeder + */ +public class BaseServletSystem extends BaseFrameworkSystem { +} diff --git a/src/org/mxchange/jcoreee/beans/BaseFrameworkBean.java b/src/org/mxchange/jcoreee/beans/BaseFrameworkBean.java new file mode 100644 index 0000000..295adf3 --- /dev/null +++ b/src/org/mxchange/jcoreee/beans/BaseFrameworkBean.java @@ -0,0 +1,75 @@ +/* + * 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.jcoreee.beans; + +import javax.enterprise.context.Dependent; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +/** + * A general bean class. Do not put things in here that are not serializable. + * The logger is currently not serializable, so you will get error messages. + * + * @author Roland Haeder + */ +@Dependent +public abstract class BaseFrameworkBean implements FrameworkBean { + + /** + * Serial number + */ + private static final long serialVersionUID = 83258139481372814L; + + /** + * Class' logger + */ + private final Logger LOG; + + /** + * Initializer + */ + { + // Get logger + this.LOG = LogManager.getLogger(this); + } + + /** + * Protected constructor, please don't add init() call here. + */ + protected BaseFrameworkBean () { + } + + /** + * Getter for logger + * + * @return Logger + */ + protected Logger getLogger () { + return this.LOG; + } + + /** + * Super initialization method. Do not set @PostConstruct here. If you overwrite this method, please call it + * before (!) your own initialization. + * + * @throws RuntimeException If something unexpected happens + */ + @Override + public void init () throws RuntimeException { + // Empty for now + } +} diff --git a/src/org/mxchange/jcoreee/beans/FrameworkBean.java b/src/org/mxchange/jcoreee/beans/FrameworkBean.java new file mode 100644 index 0000000..744317e --- /dev/null +++ b/src/org/mxchange/jcoreee/beans/FrameworkBean.java @@ -0,0 +1,34 @@ +/* + * 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.jcoreee.beans; + +import java.io.Serializable; + +/** + * A general bean interface + * + * @author Roland Haeder + */ +public interface FrameworkBean extends Serializable { + + /** + * Initializes this bean, mostly done with @PostConstruct + * + * @throws RuntimeException If something happens, no checked exceptions are allowed + */ + public void init () throws RuntimeException; +} diff --git a/src/org/mxchange/jcoreee/filter/servlet/BaseServletFilter.java b/src/org/mxchange/jcoreee/filter/servlet/BaseServletFilter.java new file mode 100644 index 0000000..aaf7b69 --- /dev/null +++ b/src/org/mxchange/jcoreee/filter/servlet/BaseServletFilter.java @@ -0,0 +1,80 @@ +/* + * 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.jcoreee.filter.servlet; + +import java.text.MessageFormat; +import javax.servlet.Filter; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import org.mxchange.jcore.BaseFrameworkSystem; + +/** + * A general servlet filter class. If you need to override init() or + * destroy() please always call the super method first and handle over all + * parameter. + * + * @author Roland Haeder + */ +public abstract class BaseServletFilter extends BaseFrameworkSystem implements Filter { + /** + * Configuration instance + */ + private FilterConfig config; + + /** + * Destroys this filter + */ + @Override + public void destroy () { + // Unset config instance + this.setConfig(null); + } + + /** + * Initializes this filter + * + * @param filterConfig Filter configuration + * @throws ServletException + */ + @Override + public void init (final FilterConfig filterConfig) throws ServletException { + // Trace message + this.getLogger().trace(MessageFormat.format("filterConfig={0} - CALLED!", filterConfig)); //NOI18N + + // Set config instance + this.setConfig(filterConfig); + + // Trace message + this.getLogger().trace("EXIT!"); //NOI18N + } + + /** + * Configuration instance + * @return the config + */ + protected final FilterConfig getConfig () { + return this.config; + } + + /** + * Configuration instance + * @param config the config to set + */ + private void setConfig (final FilterConfig config) { + this.config = config; + } +} diff --git a/src/org/mxchange/jcoreee/filter/servlet/utf8/Utf8ServletFilter.java b/src/org/mxchange/jcoreee/filter/servlet/utf8/Utf8ServletFilter.java new file mode 100644 index 0000000..9489991 --- /dev/null +++ b/src/org/mxchange/jcoreee/filter/servlet/utf8/Utf8ServletFilter.java @@ -0,0 +1,58 @@ +/* + * 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.jcoreee.filter.servlet.utf8; + +import java.io.IOException; +import java.text.MessageFormat; +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import org.mxchange.jcoreee.filter.servlet.BaseServletFilter; + +/** + * A HTTP filter for setting UTF-8 character encoding. + * + * @author Roland Haeder + */ +public class Utf8ServletFilter extends BaseServletFilter implements Filter { + /** + * Filter to set UTF-8 encoding + * + * @param request ServletRequest instance + * @param response ServletResponse instance + * @param chain FilterChain instance + * @throws IOException + * @throws ServletException + */ + @Override + public void doFilter (final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException { + // Trace message + this.getLogger().trace(MessageFormat.format("request={0},response={1},chain={2} - CALLED!", request, response, chain)); //NOI18N + + // Call super method + chain.doFilter(request, response); + + // Set response/request both to UTF-8 + request.setCharacterEncoding("UTF-8"); //NOI18N + response.setCharacterEncoding("UTF-8"); //NOI18N + + // Trace message + this.getLogger().trace("EXIT!"); //NOI18N + } +} diff --git a/src/org/mxchange/jcoreee/validator/BaseObjectValidator.java b/src/org/mxchange/jcoreee/validator/BaseObjectValidator.java new file mode 100644 index 0000000..6630944 --- /dev/null +++ b/src/org/mxchange/jcoreee/validator/BaseObjectValidator.java @@ -0,0 +1,131 @@ +/* + * 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.jcoreee.validator; + +import java.text.MessageFormat; +import java.util.Arrays; +import java.util.ResourceBundle; +import javax.faces.application.FacesMessage; +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; +import javax.faces.validator.Validator; +import javax.faces.validator.ValidatorException; +import org.mxchange.jcore.BaseFrameworkSystem; +import org.mxchange.jcore.FrameworkInterface; + +/** + * A general object validation class. Please implement javax.faces.validator.Validator + * (with import line!) and call preValidate(). You also may want to try out some + * other BaseFooValidator classes before directly inheriting from this class. + * + * @author Roland Haeder + */ +public abstract class BaseObjectValidator extends BaseFrameworkSystem implements FrameworkInterface, Validator { + + /** + * Needs to be implemented as the Validator interface needs to be implemented. + * + * @param context + * @param component + * @param value + * @throws ValidatorException + */ + @Override + abstract public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException; + + /** + * Initializes resource bundle + * + * @param FacesContext instance + */ + private void initResourceBundle (final FacesContext context) { + // Is it set? + if (null == this.getBundle()) { + // Set it now + setBundle(ResourceBundle.getBundle("org.mxchange.localization.bundle", context.getViewRoot().getLocale())); + } + } + + /** + * Pre-validation of value, e.g. not null + * + * @param context FacesContext instance + * @param component UIComponent instance + * @param value Value to check + * @param requiredFields Array of required field names (ending with) + * @throws ValidatorException If something more horrible went wrong + */ + protected void preValidate (final FacesContext context, final UIComponent component, final Object value, final String[] requiredFields) throws ValidatorException { + // Trace message + this.getLogger().trace(MessageFormat.format("context={0},component={1},value={2},requiredFields={3} - CALLED!", context, component, value, Arrays.toString(requiredFields))); //NOI18N + + // Set resource bundle + this.initResourceBundle(context); + + // Init message and key + FacesMessage facesMessage = null; + String errKey = "error.unknown_id"; //NOI18N + + // Get client id + String clientId = component.getClientId(); + + // Default is no field is valid + boolean isValidField = false; + + for (final String field : requiredFields) { + // Get logger + this.getLogger().debug(MessageFormat.format("field={0},clientId={1}", field, clientId)); //NOI18N + + // Is it the same? + if (clientId.endsWith(field)) { + // Is valid field + isValidField = true; + + // Is it null? + if (null == value) { + errKey = String.format("error.%s.is_null", field); //NOI18N + + // Value it null + facesMessage = new FacesMessage(this.getMessageStringFromKey(errKey)); + } + + // Abort here + break; + } + } + + // Debug message + this.getLogger().debug(MessageFormat.format("isValidField={0}", isValidField)); //NOI18N + + // Valid field? + if (!isValidField) { + // Invalid field + facesMessage = new FacesMessage(MessageFormat.format(errKey, clientId)); + } + + // Debug message + this.getLogger().debug(MessageFormat.format("facesMessage={0}", facesMessage)); //NOI18N + + // Is it not null? + if (null != facesMessage) { + throw new ValidatorException(facesMessage); + } + + // Trace message + this.getLogger().trace("EXIT!"); //NOI18N + } +} diff --git a/src/org/mxchange/jcoreee/validator/bool/BaseBooleanValidator.java b/src/org/mxchange/jcoreee/validator/bool/BaseBooleanValidator.java new file mode 100644 index 0000000..b67b5e7 --- /dev/null +++ b/src/org/mxchange/jcoreee/validator/bool/BaseBooleanValidator.java @@ -0,0 +1,105 @@ +/* + * 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.jcoreee.validator.bool; + +import java.text.MessageFormat; +import java.util.Arrays; +import javax.faces.application.FacesMessage; +import javax.faces.component.UIComponent; +import javax.faces.component.UIInput; +import javax.faces.component.ValueHolder; +import javax.faces.context.FacesContext; +import javax.faces.validator.Validator; +import javax.faces.validator.ValidatorException; +import org.mxchange.jcoreee.validator.BaseObjectValidator; + +/** + * A general boolean value validator. + * + * @author BalusC + * @author Roland Haeder + */ +public abstract class BaseBooleanValidator extends BaseObjectValidator implements Validator { + + @Override + public void preValidate (final FacesContext context, final UIComponent component, final Object value, final String[] requiredFields) throws ValidatorException { + // Trace message + this.getLogger().trace(MessageFormat.format("context={0},component={1},value={2},requiredFields={3} - CALLED!", context, component, value, Arrays.toString(requiredFields))); //NOI18N + + // Pre-validate + super.preValidate(context, component, value, requiredFields); + + // Get client id and init message + key + String clientId = component.getClientId(); + FacesMessage facesMessage = null; + + // So far all fine, no check if the field is fine + for (final String field : requiredFields) { + // Debug message + this.getLogger().debug(MessageFormat.format("field={0},clientId={1}", field, clientId)); //NOI18N + + // Is it the same? + if (clientId.endsWith(field)) { + // Compare value's type + if (!(value instanceof Boolean)) { + // Value is not right type + facesMessage = new FacesMessage(this.getMessageStringFromKey(String.format("error.%s.is_not_boolean", field))); //NOI18N + break; + } + + // Cast to string + Boolean bool = (Boolean) value; + + // Is it false? + if (bool.equals(Boolean.FALSE)) { + // Default message + String requiredMessage = ((UIInput) component).getRequiredMessage(); + + if (null == requiredMessage) { + Object label = component.getAttributes().get("label"); //NOI18N + + // Check if label is null, or zero length + if ((null == label) || (label instanceof CharSequence && ((CharSequence) label).length() == 0)) { + label = component.getValueExpression("label"); //NOI18N + } + + // Label is still null? + if (null == label) { + label = component.getClientId(context); + } + + // Set message + requiredMessage = MessageFormat.format(UIInput.REQUIRED_MESSAGE_ID, label); + + // Set value to false in UI component + ((ValueHolder) component).setValue(Boolean.FALSE); + } + + // Abort processing here + facesMessage = new FacesMessage(FacesMessage.SEVERITY_ERROR, requiredMessage, requiredMessage); + break; + } + } + } + + // Is facesMessage set? + if (facesMessage != null) { + // Abort here + throw new ValidatorException(facesMessage); + } + } +} diff --git a/src/org/mxchange/jcoreee/validator/bool/privacy_terms/PrivacyTermsCheckboxValidator.java b/src/org/mxchange/jcoreee/validator/bool/privacy_terms/PrivacyTermsCheckboxValidator.java new file mode 100644 index 0000000..9b14869 --- /dev/null +++ b/src/org/mxchange/jcoreee/validator/bool/privacy_terms/PrivacyTermsCheckboxValidator.java @@ -0,0 +1,47 @@ +/* + * 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.jcoreee.validator.bool.privacy_terms; + +import java.text.MessageFormat; +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; +import javax.faces.validator.Validator; +import javax.faces.validator.ValidatorException; +import org.mxchange.jcoreee.validator.bool.BaseBooleanValidator; + +/** + * A validator for privacy and terms checkboxes + * + * @author Roland Haeder + */ +public class PrivacyTermsCheckboxValidator extends BaseBooleanValidator implements Validator { + + @Override + public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException { + // Trace message + this.getLogger().trace(MessageFormat.format("context={0},component={1},value={2} - CALLED!", context, component, value)); //NOI18N + + // All accepted, required fields + String[] requiredFileds = {"privacy", "terms"}; //NOI18N + + // Pre-validation (e.g. not null, not a string, empty string ...) + super.preValidate(context, component, value, requiredFileds); + + // Trace message + this.getLogger().trace("EXIT!"); //NOI18N + } +} diff --git a/src/org/mxchange/jcoreee/validator/string/BaseStringValidator.java b/src/org/mxchange/jcoreee/validator/string/BaseStringValidator.java new file mode 100644 index 0000000..c7316a2 --- /dev/null +++ b/src/org/mxchange/jcoreee/validator/string/BaseStringValidator.java @@ -0,0 +1,87 @@ +/* + * 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.jcoreee.validator.string; + +import java.text.MessageFormat; +import java.util.Arrays; +import javax.faces.application.FacesMessage; +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; +import javax.faces.validator.ValidatorException; +import org.mxchange.jcoreee.validator.BaseObjectValidator; + +/** + * A general string validation class. You normally want to inherit from this + * class for many form fields, e.g. surname, street name, city name and such. + * + * @author Roland Haeder + */ +public abstract class BaseStringValidator extends BaseObjectValidator { + + @Override + protected void preValidate (final FacesContext context, final UIComponent component, final Object value, final String[] requiredFields) throws ValidatorException { + // Trace message + this.getLogger().trace(MessageFormat.format("context={0},component={1},value={2},fields={3} - CALLED!", context, component, value, Arrays.toString(requiredFields))); //NOI18N + + // Pre-validate (e.g. on null) + super.preValidate(context, component, value, requiredFields); + + // Get client id and init message + key + String clientId = component.getClientId(); + FacesMessage facesMessage = null; + String errKey; + + // So far all fine, no check if the field is fine + for (final String field : requiredFields) { + // Debug message + this.getLogger().debug(MessageFormat.format("field={0},clientId={1}", field, clientId)); //NOI18N + + // Is it the same? + if (clientId.endsWith(field)) { + // Compare value's type + if (!(value instanceof String)) { + // Value is empty + errKey = String.format("error.%s.is_not_string", field); //NOI18N + + facesMessage = new FacesMessage(this.getMessageStringFromKey(errKey)); + } + + // Cast to string + String str = (String) value; + + // Is it empty? + if (str.isEmpty()) { + // Value is empty + errKey = String.format("error.%s.is_empty", field); //NOI18N + + facesMessage = new FacesMessage(this.getMessageStringFromKey(errKey)); + } + } + } + + // Debug message + this.getLogger().debug(MessageFormat.format("facesMessage={0}", facesMessage)); //NOI18N + + // Is it not null? + if (null != facesMessage) { + throw new ValidatorException(facesMessage); + } + + // Trace message + this.getLogger().trace("EXIT!"); //NOI18N + } +} diff --git a/src/org/mxchange/jcoreee/validator/string/names/NameValidator.java b/src/org/mxchange/jcoreee/validator/string/names/NameValidator.java new file mode 100644 index 0000000..8325169 --- /dev/null +++ b/src/org/mxchange/jcoreee/validator/string/names/NameValidator.java @@ -0,0 +1,46 @@ +/* + * 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.jcoreee.validator.string.names; + +import java.text.MessageFormat; +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; +import javax.faces.validator.Validator; +import javax.faces.validator.ValidatorException; +import org.mxchange.jcoreee.validator.string.BaseStringValidator; + +/** + * A validation class for names, such as first name or family name. + * + * @author Roland Haeder + */ +public class NameValidator extends BaseStringValidator implements Validator { + @Override + public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException { + // Trace message + this.getLogger().trace(MessageFormat.format("context={0},component={1},value={2} - CALLED!", context, component, value)); //NOI18N + + // All accepted, required fields + String[] requiredFileds = {"firstName", "familyName", "city", "street"}; //NOI18N + + // Pre-validation (e.g. not null, not a string, empty string ...) + super.preValidate(context, component, value, requiredFileds); + + // Trace message + this.getLogger().trace("EXIT!"); //NOI18N + } +} diff --git a/src/org/mxchange/jcoreejb/BaseServletSystem.java b/src/org/mxchange/jcoreejb/BaseServletSystem.java deleted file mode 100644 index 97a7714..0000000 --- a/src/org/mxchange/jcoreejb/BaseServletSystem.java +++ /dev/null @@ -1,26 +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.jcoreejb; - -import org.mxchange.jcore.BaseFrameworkSystem; - -/** - * A general shop class - * @author Roland Haeder - */ -public class BaseServletSystem extends BaseFrameworkSystem { -} diff --git a/src/org/mxchange/jcoreejb/beans/BaseFrameworkBean.java b/src/org/mxchange/jcoreejb/beans/BaseFrameworkBean.java deleted file mode 100644 index 7facda6..0000000 --- a/src/org/mxchange/jcoreejb/beans/BaseFrameworkBean.java +++ /dev/null @@ -1,75 +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.jcoreejb.beans; - -import javax.enterprise.context.Dependent; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -/** - * A general bean class. Do not put things in here that are not serializable. - * The logger is currently not serializable, so you will get error messages. - * - * @author Roland Haeder - */ -@Dependent -public abstract class BaseFrameworkBean implements FrameworkBean { - - /** - * Serial number - */ - private static final long serialVersionUID = 83258139481372814L; - - /** - * Class' logger - */ - private final Logger LOG; - - /** - * Initializer - */ - { - // Get logger - this.LOG = LogManager.getLogger(this); - } - - /** - * Protected constructor, please don't add init() call here. - */ - protected BaseFrameworkBean () { - } - - /** - * Getter for logger - * - * @return Logger - */ - protected Logger getLogger () { - return this.LOG; - } - - /** - * Super initialization method. Do not set @PostConstruct here. If you overwrite this method, please call it - * before (!) your own initialization. - * - * @throws RuntimeException If something unexpected happens - */ - @Override - public void init () throws RuntimeException { - // Empty for now - } -} diff --git a/src/org/mxchange/jcoreejb/beans/FrameworkBean.java b/src/org/mxchange/jcoreejb/beans/FrameworkBean.java deleted file mode 100644 index 37599c1..0000000 --- a/src/org/mxchange/jcoreejb/beans/FrameworkBean.java +++ /dev/null @@ -1,34 +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.jcoreejb.beans; - -import java.io.Serializable; - -/** - * A general bean interface - * - * @author Roland Haeder - */ -public interface FrameworkBean extends Serializable { - - /** - * Initializes this bean, mostly done with @PostConstruct - * - * @throws RuntimeException If something happens, no checked exceptions are allowed - */ - public void init () throws RuntimeException; -} diff --git a/src/org/mxchange/jcoreejb/filter/servlet/BaseServletFilter.java b/src/org/mxchange/jcoreejb/filter/servlet/BaseServletFilter.java deleted file mode 100644 index f4e7ddb..0000000 --- a/src/org/mxchange/jcoreejb/filter/servlet/BaseServletFilter.java +++ /dev/null @@ -1,80 +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.jcoreejb.filter.servlet; - -import java.text.MessageFormat; -import javax.servlet.Filter; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import org.mxchange.jcore.BaseFrameworkSystem; - -/** - * A general servlet filter class. If you need to override init() or - * destroy() please always call the super method first and handle over all - * parameter. - * - * @author Roland Haeder - */ -public abstract class BaseServletFilter extends BaseFrameworkSystem implements Filter { - /** - * Configuration instance - */ - private FilterConfig config; - - /** - * Destroys this filter - */ - @Override - public void destroy () { - // Unset config instance - this.setConfig(null); - } - - /** - * Initializes this filter - * - * @param filterConfig Filter configuration - * @throws ServletException - */ - @Override - public void init (final FilterConfig filterConfig) throws ServletException { - // Trace message - this.getLogger().trace(MessageFormat.format("filterConfig={0} - CALLED!", filterConfig)); //NOI18N - - // Set config instance - this.setConfig(filterConfig); - - // Trace message - this.getLogger().trace("EXIT!"); //NOI18N - } - - /** - * Configuration instance - * @return the config - */ - protected final FilterConfig getConfig () { - return this.config; - } - - /** - * Configuration instance - * @param config the config to set - */ - private void setConfig (final FilterConfig config) { - this.config = config; - } -} diff --git a/src/org/mxchange/jcoreejb/filter/servlet/utf8/Utf8ServletFilter.java b/src/org/mxchange/jcoreejb/filter/servlet/utf8/Utf8ServletFilter.java deleted file mode 100644 index 29d0cdf..0000000 --- a/src/org/mxchange/jcoreejb/filter/servlet/utf8/Utf8ServletFilter.java +++ /dev/null @@ -1,58 +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.jcoreejb.filter.servlet.utf8; - -import java.io.IOException; -import java.text.MessageFormat; -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import org.mxchange.jcoreejb.filter.servlet.BaseServletFilter; - -/** - * A HTTP filter for setting UTF-8 character encoding. - * - * @author Roland Haeder - */ -public class Utf8ServletFilter extends BaseServletFilter implements Filter { - /** - * Filter to set UTF-8 encoding - * - * @param request ServletRequest instance - * @param response ServletResponse instance - * @param chain FilterChain instance - * @throws IOException - * @throws ServletException - */ - @Override - public void doFilter (final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException { - // Trace message - this.getLogger().trace(MessageFormat.format("request={0},response={1},chain={2} - CALLED!", request, response, chain)); //NOI18N - - // Call super method - chain.doFilter(request, response); - - // Set response/request both to UTF-8 - request.setCharacterEncoding("UTF-8"); //NOI18N - response.setCharacterEncoding("UTF-8"); //NOI18N - - // Trace message - this.getLogger().trace("EXIT!"); //NOI18N - } -} diff --git a/src/org/mxchange/jcoreejb/validator/BaseObjectValidator.java b/src/org/mxchange/jcoreejb/validator/BaseObjectValidator.java deleted file mode 100644 index 6ee76ce..0000000 --- a/src/org/mxchange/jcoreejb/validator/BaseObjectValidator.java +++ /dev/null @@ -1,131 +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.jcoreejb.validator; - -import java.text.MessageFormat; -import java.util.Arrays; -import java.util.ResourceBundle; -import javax.faces.application.FacesMessage; -import javax.faces.component.UIComponent; -import javax.faces.context.FacesContext; -import javax.faces.validator.Validator; -import javax.faces.validator.ValidatorException; -import org.mxchange.jcore.BaseFrameworkSystem; -import org.mxchange.jcore.FrameworkInterface; - -/** - * A general object validation class. Please implement javax.faces.validator.Validator - * (with import line!) and call preValidate(). You also may want to try out some - * other BaseFooValidator classes before directly inheriting from this class. - * - * @author Roland Haeder - */ -public abstract class BaseObjectValidator extends BaseFrameworkSystem implements FrameworkInterface, Validator { - - /** - * Needs to be implemented as the Validator interface needs to be implemented. - * - * @param context - * @param component - * @param value - * @throws ValidatorException - */ - @Override - abstract public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException; - - /** - * Initializes resource bundle - * - * @param FacesContext instance - */ - private void initResourceBundle (final FacesContext context) { - // Is it set? - if (null == this.getBundle()) { - // Set it now - setBundle(ResourceBundle.getBundle("org.mxchange.localization.bundle", context.getViewRoot().getLocale())); - } - } - - /** - * Pre-validation of value, e.g. not null - * - * @param context FacesContext instance - * @param component UIComponent instance - * @param value Value to check - * @param requiredFields Array of required field names (ending with) - * @throws ValidatorException If something more horrible went wrong - */ - protected void preValidate (final FacesContext context, final UIComponent component, final Object value, final String[] requiredFields) throws ValidatorException { - // Trace message - this.getLogger().trace(MessageFormat.format("context={0},component={1},value={2},requiredFields={3} - CALLED!", context, component, value, Arrays.toString(requiredFields))); //NOI18N - - // Set resource bundle - this.initResourceBundle(context); - - // Init message and key - FacesMessage facesMessage = null; - String errKey = "error.unknown_id"; //NOI18N - - // Get client id - String clientId = component.getClientId(); - - // Default is no field is valid - boolean isValidField = false; - - for (final String field : requiredFields) { - // Get logger - this.getLogger().debug(MessageFormat.format("field={0},clientId={1}", field, clientId)); //NOI18N - - // Is it the same? - if (clientId.endsWith(field)) { - // Is valid field - isValidField = true; - - // Is it null? - if (null == value) { - errKey = String.format("error.%s.is_null", field); //NOI18N - - // Value it null - facesMessage = new FacesMessage(this.getMessageStringFromKey(errKey)); - } - - // Abort here - break; - } - } - - // Debug message - this.getLogger().debug(MessageFormat.format("isValidField={0}", isValidField)); //NOI18N - - // Valid field? - if (!isValidField) { - // Invalid field - facesMessage = new FacesMessage(MessageFormat.format(errKey, clientId)); - } - - // Debug message - this.getLogger().debug(MessageFormat.format("facesMessage={0}", facesMessage)); //NOI18N - - // Is it not null? - if (null != facesMessage) { - throw new ValidatorException(facesMessage); - } - - // Trace message - this.getLogger().trace("EXIT!"); //NOI18N - } -} diff --git a/src/org/mxchange/jcoreejb/validator/bool/BaseBooleanValidator.java b/src/org/mxchange/jcoreejb/validator/bool/BaseBooleanValidator.java deleted file mode 100644 index 12ba522..0000000 --- a/src/org/mxchange/jcoreejb/validator/bool/BaseBooleanValidator.java +++ /dev/null @@ -1,105 +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.jcoreejb.validator.bool; - -import java.text.MessageFormat; -import java.util.Arrays; -import javax.faces.application.FacesMessage; -import javax.faces.component.UIComponent; -import javax.faces.component.UIInput; -import javax.faces.component.ValueHolder; -import javax.faces.context.FacesContext; -import javax.faces.validator.Validator; -import javax.faces.validator.ValidatorException; -import org.mxchange.jcoreejb.validator.BaseObjectValidator; - -/** - * A general boolean value validator. - * - * @author BalusC - * @author Roland Haeder - */ -public abstract class BaseBooleanValidator extends BaseObjectValidator implements Validator { - - @Override - public void preValidate (final FacesContext context, final UIComponent component, final Object value, final String[] requiredFields) throws ValidatorException { - // Trace message - this.getLogger().trace(MessageFormat.format("context={0},component={1},value={2},requiredFields={3} - CALLED!", context, component, value, Arrays.toString(requiredFields))); //NOI18N - - // Pre-validate - super.preValidate(context, component, value, requiredFields); - - // Get client id and init message + key - String clientId = component.getClientId(); - FacesMessage facesMessage = null; - - // So far all fine, no check if the field is fine - for (final String field : requiredFields) { - // Debug message - this.getLogger().debug(MessageFormat.format("field={0},clientId={1}", field, clientId)); //NOI18N - - // Is it the same? - if (clientId.endsWith(field)) { - // Compare value's type - if (!(value instanceof Boolean)) { - // Value is not right type - facesMessage = new FacesMessage(this.getMessageStringFromKey(String.format("error.%s.is_not_boolean", field))); //NOI18N - break; - } - - // Cast to string - Boolean bool = (Boolean) value; - - // Is it false? - if (bool.equals(Boolean.FALSE)) { - // Default message - String requiredMessage = ((UIInput) component).getRequiredMessage(); - - if (null == requiredMessage) { - Object label = component.getAttributes().get("label"); //NOI18N - - // Check if label is null, or zero length - if ((null == label) || (label instanceof CharSequence && ((CharSequence) label).length() == 0)) { - label = component.getValueExpression("label"); //NOI18N - } - - // Label is still null? - if (null == label) { - label = component.getClientId(context); - } - - // Set message - requiredMessage = MessageFormat.format(UIInput.REQUIRED_MESSAGE_ID, label); - - // Set value to false in UI component - ((ValueHolder) component).setValue(Boolean.FALSE); - } - - // Abort processing here - facesMessage = new FacesMessage(FacesMessage.SEVERITY_ERROR, requiredMessage, requiredMessage); - break; - } - } - } - - // Is facesMessage set? - if (facesMessage != null) { - // Abort here - throw new ValidatorException(facesMessage); - } - } -} diff --git a/src/org/mxchange/jcoreejb/validator/bool/privacy_terms/PrivacyTermsCheckboxValidator.java b/src/org/mxchange/jcoreejb/validator/bool/privacy_terms/PrivacyTermsCheckboxValidator.java deleted file mode 100644 index 7e55306..0000000 --- a/src/org/mxchange/jcoreejb/validator/bool/privacy_terms/PrivacyTermsCheckboxValidator.java +++ /dev/null @@ -1,47 +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.jcoreejb.validator.bool.privacy_terms; - -import java.text.MessageFormat; -import javax.faces.component.UIComponent; -import javax.faces.context.FacesContext; -import javax.faces.validator.Validator; -import javax.faces.validator.ValidatorException; -import org.mxchange.jcoreejb.validator.bool.BaseBooleanValidator; - -/** - * A validator for privacy and terms checkboxes - * - * @author Roland Haeder - */ -public class PrivacyTermsCheckboxValidator extends BaseBooleanValidator implements Validator { - - @Override - public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException { - // Trace message - this.getLogger().trace(MessageFormat.format("context={0},component={1},value={2} - CALLED!", context, component, value)); //NOI18N - - // All accepted, required fields - String[] requiredFileds = {"privacy", "terms"}; //NOI18N - - // Pre-validation (e.g. not null, not a string, empty string ...) - super.preValidate(context, component, value, requiredFileds); - - // Trace message - this.getLogger().trace("EXIT!"); //NOI18N - } -} diff --git a/src/org/mxchange/jcoreejb/validator/string/BaseStringValidator.java b/src/org/mxchange/jcoreejb/validator/string/BaseStringValidator.java deleted file mode 100644 index 4f96521..0000000 --- a/src/org/mxchange/jcoreejb/validator/string/BaseStringValidator.java +++ /dev/null @@ -1,87 +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.jcoreejb.validator.string; - -import java.text.MessageFormat; -import java.util.Arrays; -import javax.faces.application.FacesMessage; -import javax.faces.component.UIComponent; -import javax.faces.context.FacesContext; -import javax.faces.validator.ValidatorException; -import org.mxchange.jcoreejb.validator.BaseObjectValidator; - -/** - * A general string validation class. You normally want to inherit from this - * class for many form fields, e.g. surname, street name, city name and such. - * - * @author Roland Haeder - */ -public abstract class BaseStringValidator extends BaseObjectValidator { - - @Override - protected void preValidate (final FacesContext context, final UIComponent component, final Object value, final String[] requiredFields) throws ValidatorException { - // Trace message - this.getLogger().trace(MessageFormat.format("context={0},component={1},value={2},fields={3} - CALLED!", context, component, value, Arrays.toString(requiredFields))); //NOI18N - - // Pre-validate (e.g. on null) - super.preValidate(context, component, value, requiredFields); - - // Get client id and init message + key - String clientId = component.getClientId(); - FacesMessage facesMessage = null; - String errKey; - - // So far all fine, no check if the field is fine - for (final String field : requiredFields) { - // Debug message - this.getLogger().debug(MessageFormat.format("field={0},clientId={1}", field, clientId)); //NOI18N - - // Is it the same? - if (clientId.endsWith(field)) { - // Compare value's type - if (!(value instanceof String)) { - // Value is empty - errKey = String.format("error.%s.is_not_string", field); //NOI18N - - facesMessage = new FacesMessage(this.getMessageStringFromKey(errKey)); - } - - // Cast to string - String str = (String) value; - - // Is it empty? - if (str.isEmpty()) { - // Value is empty - errKey = String.format("error.%s.is_empty", field); //NOI18N - - facesMessage = new FacesMessage(this.getMessageStringFromKey(errKey)); - } - } - } - - // Debug message - this.getLogger().debug(MessageFormat.format("facesMessage={0}", facesMessage)); //NOI18N - - // Is it not null? - if (null != facesMessage) { - throw new ValidatorException(facesMessage); - } - - // Trace message - this.getLogger().trace("EXIT!"); //NOI18N - } -} diff --git a/src/org/mxchange/jcoreejb/validator/string/names/NameValidator.java b/src/org/mxchange/jcoreejb/validator/string/names/NameValidator.java deleted file mode 100644 index 7ef0c65..0000000 --- a/src/org/mxchange/jcoreejb/validator/string/names/NameValidator.java +++ /dev/null @@ -1,46 +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.jcoreejb.validator.string.names; - -import java.text.MessageFormat; -import javax.faces.component.UIComponent; -import javax.faces.context.FacesContext; -import javax.faces.validator.Validator; -import javax.faces.validator.ValidatorException; -import org.mxchange.jcoreejb.validator.string.BaseStringValidator; - -/** - * A validation class for names, such as first name or family name. - * - * @author Roland Haeder - */ -public class NameValidator extends BaseStringValidator implements Validator { - @Override - public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException { - // Trace message - this.getLogger().trace(MessageFormat.format("context={0},component={1},value={2} - CALLED!", context, component, value)); //NOI18N - - // All accepted, required fields - String[] requiredFileds = {"firstName", "familyName", "city", "street"}; //NOI18N - - // Pre-validation (e.g. not null, not a string, empty string ...) - super.preValidate(context, component, value, requiredFileds); - - // Trace message - this.getLogger().trace("EXIT!"); //NOI18N - } -}