From: Roland Haeder Date: Thu, 27 Aug 2015 13:33:35 +0000 (+0200) Subject: New jar for new jcore added X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=c629cfd8cafc5af4fb23baf92b8b8a822aa53294;p=jcoreee.git New jar for new jcore added Signed-off-by:Roland Haeder --- diff --git a/lib/commons-lang3-3.4.jar b/lib/commons-lang3-3.4.jar new file mode 100644 index 0000000..8ec91d4 Binary files /dev/null and b/lib/commons-lang3-3.4.jar differ diff --git a/lib/jcore.jar b/lib/jcore.jar index 79c62fe..68d4537 100644 Binary files a/lib/jcore.jar and b/lib/jcore.jar differ diff --git a/nbproject/project.properties b/nbproject/project.properties index 946691c..957a299 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -31,6 +31,7 @@ dist.javadoc.dir=${dist.dir}/javadoc endorsed.classpath= excludes= file.reference.commons-codec-1.10.jar=lib/commons-codec-1.10.jar +file.reference.commons-lang3-3.4.jar=lib\\commons-lang3-3.4.jar file.reference.jcore.jar=lib/jcore.jar file.reference.log4j-api-2.3.jar=lib/log4j-api-2.3.jar file.reference.log4j-core-2.3.jar=lib/log4j-core-2.3.jar @@ -41,7 +42,8 @@ javac.classpath=\ ${file.reference.log4j-api-2.3.jar}:\ ${file.reference.log4j-core-2.3.jar}:\ ${file.reference.jcore.jar}:\ - ${libs.javaee-api-7.0.classpath} + ${libs.javaee-api-7.0.classpath}:\ + ${file.reference.commons-lang3-3.4.jar} # Space-separated list of extra javac options javac.compilerargs=-Xlint:unchecked javac.deprecation=true diff --git a/src/org/mxchange/jsfcore/validator/BaseObjectValidator.java b/src/org/mxchange/jsfcore/validator/BaseObjectValidator.java index 5cff975..c0b5fe5 100644 --- a/src/org/mxchange/jsfcore/validator/BaseObjectValidator.java +++ b/src/org/mxchange/jsfcore/validator/BaseObjectValidator.java @@ -1,128 +1,130 @@ -/* - * 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.jsfcore.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.messages", 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},fields={3} - CALLED!", context, component, value, Arrays.toString(requiredFields))); - - // Set resource bundle - this.initResourceBundle(context); - - // Init message and key - FacesMessage facesMessage = null; - String errKey = "error.unknown_id"; - - // 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)); - - // 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); - - // Value it null - facesMessage = new FacesMessage(this.getMessageStringFromKey(errKey)); - } - } - } - - // Debug message - this.getLogger().debug("isValidField=" + isValidField); - - // Valid field? - if (!isValidField) { - // Invalid field - facesMessage = new FacesMessage(MessageFormat.format(errKey, clientId)); - } - - // Debug message - this.getLogger().debug(MessageFormat.format("facesMessage={0}", facesMessage)); - - // Is it not null? - if (null != facesMessage) { - throw new ValidatorException(facesMessage); - } - - // Trace message - this.getLogger().trace("EXIT!"); - } -} +/* + * 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.jsfcore.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.messages", 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},fields={3} - CALLED!", context, component, value, Arrays.toString(requiredFields))); + + // Set resource bundle + this.initResourceBundle(context); + + // Init message and key + FacesMessage facesMessage = null; + String errKey = "error.unknown_id"; + + // 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)); + + // 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); + + // Value it null + facesMessage = new FacesMessage(this.getMessageStringFromKey(errKey)); + + // Abort here? + } + } + } + + // Debug message + this.getLogger().debug("isValidField=" + isValidField); + + // Valid field? + if (!isValidField) { + // Invalid field + facesMessage = new FacesMessage(MessageFormat.format(errKey, clientId)); + } + + // Debug message + this.getLogger().debug(MessageFormat.format("facesMessage={0}", facesMessage)); + + // Is it not null? + if (null != facesMessage) { + throw new ValidatorException(facesMessage); + } + + // Trace message + this.getLogger().trace("EXIT!"); + } +}