From: Roland Haeder Date: Tue, 1 Sep 2015 06:28:31 +0000 (+0200) Subject: Some changes for internationalization + jcore.jar updated X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=360c652015f4a6c803036bae07366a79657d4675;p=jcoreee.git Some changes for internationalization + jcore.jar updated Signed-off-by:Roland Haeder --- diff --git a/lib/jcore.jar b/lib/jcore.jar index 9571e27..8b05d57 100644 Binary files a/lib/jcore.jar and b/lib/jcore.jar differ diff --git a/src/org/mxchange/jsfcore/BaseServletSystem.java b/src/org/mxchange/jsfcore/BaseServletSystem.java index f8bdd74..b9c5295 100644 --- a/src/org/mxchange/jsfcore/BaseServletSystem.java +++ b/src/org/mxchange/jsfcore/BaseServletSystem.java @@ -36,7 +36,7 @@ public class BaseServletSystem extends BaseFrameworkSystem { // context shall not be null if (null == context) { // Abort here - throw new NullPointerException("context is null"); + throw new NullPointerException("context is null"); //NOI18N } // We need some properties that needs to be set diff --git a/src/org/mxchange/jsfcore/validator/BaseObjectValidator.java b/src/org/mxchange/jsfcore/validator/BaseObjectValidator.java index c0b5fe5..ad4ea8b 100644 --- a/src/org/mxchange/jsfcore/validator/BaseObjectValidator.java +++ b/src/org/mxchange/jsfcore/validator/BaseObjectValidator.java @@ -71,14 +71,14 @@ public abstract class BaseObjectValidator extends BaseFrameworkSystem implements */ 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))); + this.getLogger().trace(MessageFormat.format("context={0},component={1},value={2},fields={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"; + String errKey = "error.unknown_id"; //NOI18N // Get client id String clientId = component.getClientId(); @@ -88,7 +88,7 @@ public abstract class BaseObjectValidator extends BaseFrameworkSystem implements for (final String field : requiredFields) { // Get logger - this.getLogger().debug(MessageFormat.format("field={0},clientId={1}", field, clientId)); + this.getLogger().debug(MessageFormat.format("field={0},clientId={1}", field, clientId)); //NOI18N // Is it the same? if (clientId.endsWith(field)) { @@ -97,7 +97,7 @@ public abstract class BaseObjectValidator extends BaseFrameworkSystem implements // Is it null? if (null == value) { - errKey = String.format("error.%s.is_null", field); + errKey = String.format("error.%s.is_null", field); //NOI18N // Value it null facesMessage = new FacesMessage(this.getMessageStringFromKey(errKey)); @@ -108,7 +108,7 @@ public abstract class BaseObjectValidator extends BaseFrameworkSystem implements } // Debug message - this.getLogger().debug("isValidField=" + isValidField); + this.getLogger().debug(MessageFormat.format("isValidField={0}", isValidField)); //NOI18N // Valid field? if (!isValidField) { @@ -117,7 +117,7 @@ public abstract class BaseObjectValidator extends BaseFrameworkSystem implements } // Debug message - this.getLogger().debug(MessageFormat.format("facesMessage={0}", facesMessage)); + this.getLogger().debug(MessageFormat.format("facesMessage={0}", facesMessage)); //NOI18N // Is it not null? if (null != facesMessage) { @@ -125,6 +125,6 @@ public abstract class BaseObjectValidator extends BaseFrameworkSystem implements } // Trace message - this.getLogger().trace("EXIT!"); + this.getLogger().trace("EXIT!"); //NOI18N } } diff --git a/src/org/mxchange/jsfcore/validator/string/BaseStringValidator.java b/src/org/mxchange/jsfcore/validator/string/BaseStringValidator.java index 6434cb9..43aa7c1 100644 --- a/src/org/mxchange/jsfcore/validator/string/BaseStringValidator.java +++ b/src/org/mxchange/jsfcore/validator/string/BaseStringValidator.java @@ -1,95 +1,95 @@ -/* - * 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.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.jsfcore.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 { - - /** - * 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 - */ - @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))); - - // 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! - for (final String field : requiredFields) { - // Debug message - this.getLogger().debug(MessageFormat.format("field={0},clientId={1}", field, clientId)); - - // Is it the same? - if (clientId.endsWith(field)) { - if (!(value instanceof String)) { - // Value is empty - errKey = String.format("error.%s.is_not_string", field); - - 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); - - facesMessage = new FacesMessage(this.getMessageStringFromKey(errKey)); - } - } - } - - // 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.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.jsfcore.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 { + + /** + * 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 + */ + @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! + 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)) { + 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/jsfcore/validator/string/names/NameValidator.java b/src/org/mxchange/jsfcore/validator/string/names/NameValidator.java index 45b4cf7..4186545 100644 --- a/src/org/mxchange/jsfcore/validator/string/names/NameValidator.java +++ b/src/org/mxchange/jsfcore/validator/string/names/NameValidator.java @@ -1,46 +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.jsfcore.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.jsfcore.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)); - - // All accepted, required fields - String[] requiredFileds = {"firstName", "familyName"}; - - // Pre-validation (e.g. not null, not a string, empty string ...) - super.preValidate(context, component, value, requiredFileds); - - // 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.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.jsfcore.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"}; //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 + } +}