From eadf3b1db64131882abb04abe7b58acb21312303 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Thu, 10 Sep 2015 15:39:17 +0200 Subject: [PATCH] =?utf8?q?Updated=20author=20(email=20address)=20+=20updat?= =?utf8?q?ed=20jars=20Signed-off-by:Roland=20H=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- lib/jcore-ee-logger.jar | Bin 8032 -> 8032 bytes src/org/mxchange/jcoreee/BaseEeSystem.java | 2 +- .../jcoreee/beans/BaseFrameworkBean.java | 24 +++++++- .../validator/BaseObjectValidator.java | 53 ++++++------------ .../validator/bool/BaseBooleanValidator.java | 7 +-- .../PrivacyTermsCheckboxValidator.java | 7 +-- .../validator/string/BaseStringValidator.java | 13 ++--- .../validator/string/names/NameValidator.java | 10 ++-- 8 files changed, 55 insertions(+), 61 deletions(-) diff --git a/lib/jcore-ee-logger.jar b/lib/jcore-ee-logger.jar index 5ebf6d07bb973bde224c28c9e8403af3719390fe..c65212243809f11f3ffb24a9b60a199155e03c07 100644 GIT binary patch delta 212 zcmaE0_rQ)Pz?+$ci-CcIfuXf}B9A6hOZ7za=}bWO1qBfKNfSs;mSr>tQDKa>AZjY3 zGl;sy=mn%Ut1-neg6I}zWfl;C5tQDKa>AZjY3 zGl;sy=mn%Ut1-neg6I}zWfl;C5 */ public class BaseEeSystem { /** diff --git a/src/org/mxchange/jcoreee/beans/BaseFrameworkBean.java b/src/org/mxchange/jcoreee/beans/BaseFrameworkBean.java index 9d70e50..0a62f6e 100644 --- a/src/org/mxchange/jcoreee/beans/BaseFrameworkBean.java +++ b/src/org/mxchange/jcoreee/beans/BaseFrameworkBean.java @@ -17,12 +17,13 @@ package org.mxchange.jcoreee.beans; import java.io.Serializable; +import java.util.ResourceBundle; /** * 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 + * @author Roland Haeder */ public abstract class BaseFrameworkBean implements Serializable { @@ -31,6 +32,11 @@ public abstract class BaseFrameworkBean implements Serializable { */ private static final long serialVersionUID = 83_258_139_481_372_814L; + /** + * Resource bundle + */ + private ResourceBundle bundle; + /** * Protected constructor, please don't add init() call here. */ @@ -38,11 +44,23 @@ public abstract class BaseFrameworkBean implements Serializable { } /** - * Super initialization method. If you overwrite this method, please call it before (!) your own initialization. + * Super initialization method. If you overwrite this method, please call it + * before (!) your own initialization. * * @throws RuntimeException If something unexpected happens */ protected void genericInit () throws RuntimeException { - // Empty for now + // Init resource bundle + this.bundle = ResourceBundle.getBundle("org/mxchange/localization/bundle"); + } + + /** + * Getter for localized message from key + * + * @param key Key for message + * @return Localized message + */ + protected String getMessage (final String key) { + return this.bundle.getString(key); } } diff --git a/src/org/mxchange/jcoreee/validator/BaseObjectValidator.java b/src/org/mxchange/jcoreee/validator/BaseObjectValidator.java index 703e9ab..5e9d14a 100644 --- a/src/org/mxchange/jcoreee/validator/BaseObjectValidator.java +++ b/src/org/mxchange/jcoreee/validator/BaseObjectValidator.java @@ -17,48 +17,40 @@ package org.mxchange.jcoreee.validator; import java.text.MessageFormat; -import java.util.Arrays; -import javax.ejb.EJB; 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.jcoreee.BaseEeSystem; -import org.mxchange.jcoreeelogger.beans.local.logger.Log; -import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal; /** - * 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. + * 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 + * @author Roland Haeder */ public abstract class BaseObjectValidator extends BaseEeSystem implements Validator { /** - * Logger instance - */ - @EJB - @Log - private LoggerBeanLocal logger; - - /** - * Needs to be implemented as the Validator interface needs to be implemented. + * Needs to be implemented as the Validator interface needs to be + * implemented. * * @param context * @param component * @param value - * @throws ValidatorException + * @throws ValidatorException */ @Override abstract public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException; /** - * The method pre-validates the given value. It makes sure that the component's id is found in - * requiredFields and is not null. Once the component's id has been found, it stops iteration on - * requiredFields (which saves execution time). + * The method pre-validates the given value. It makes sure that the + * component's id is found in requiredFields and is not null. Once the + * component's id has been found, it stops iteration on requiredFields + * (which saves execution time). * * @param context FacesContext instance * @param component UIComponent instance @@ -68,7 +60,7 @@ public abstract class BaseObjectValidator extends BaseEeSystem implements Valida */ protected void preValidate (final FacesContext context, final UIComponent component, final Object value, final String[] requiredFields) throws ValidatorException { // Trace message - this.getLogger().logTrace(MessageFormat.format("preValidate: context={0},component={1},value={2},requiredFields={3} - CALLED!", context, component, value, Arrays.toString(requiredFields))); //NOI18N + //this.getLogger().logTrace(MessageFormat.format("preValidate: context={0},component={1},value={2},requiredFields={3} - CALLED!", context, component, value, Arrays.toString(requiredFields))); //NOI18N // Init message and key FacesMessage facesMessage = null; @@ -83,7 +75,7 @@ public abstract class BaseObjectValidator extends BaseEeSystem implements Valida // Check component's id against required fields and find a match for (final String field : requiredFields) { // Get logger - this.getLogger().logDebug(MessageFormat.format("preValidate: field={0},clientId={1}", field, clientId)); //NOI18N + //this.getLogger().logDebug(MessageFormat.format("preValidate: field={0},clientId={1}", field, clientId)); //NOI18N // Is it the same? if (clientId.endsWith(field)) { @@ -104,8 +96,7 @@ public abstract class BaseObjectValidator extends BaseEeSystem implements Valida } // Debug message - this.getLogger().logDebug(MessageFormat.format("preValidate: isValidField={0}", isValidField)); //NOI18N - + //this.getLogger().logDebug(MessageFormat.format("preValidate: isValidField={0}", isValidField)); //NOI18N // Valid field? if (!isValidField) { // Invalid field @@ -113,23 +104,13 @@ public abstract class BaseObjectValidator extends BaseEeSystem implements Valida } // Debug message - this.getLogger().logDebug(MessageFormat.format("preValidate: facesMessage={0}", facesMessage)); //NOI18N - + //this.getLogger().logDebug(MessageFormat.format("preValidate: facesMessage={0}", facesMessage)); //NOI18N // Is it not null? if (null != facesMessage) { throw new ValidatorException(facesMessage); } // Trace message - this.getLogger().logTrace("preValidate: EXIT!"); //NOI18N - } - - /** - * Getter for local bean logger - * - * @return Local bean logger - */ - protected LoggerBeanLocal getLogger () { - return this.logger; + //this.getLogger().logTrace("preValidate: EXIT!"); //NOI18N } } diff --git a/src/org/mxchange/jcoreee/validator/bool/BaseBooleanValidator.java b/src/org/mxchange/jcoreee/validator/bool/BaseBooleanValidator.java index 17c4f84..e0b3317 100644 --- a/src/org/mxchange/jcoreee/validator/bool/BaseBooleanValidator.java +++ b/src/org/mxchange/jcoreee/validator/bool/BaseBooleanValidator.java @@ -17,7 +17,6 @@ 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; @@ -31,14 +30,14 @@ import org.mxchange.jcoreee.validator.BaseObjectValidator; * A general boolean value validator. * * @author BalusC - * @author Roland Haeder + * @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().logTrace(MessageFormat.format("preValidate: context={0},component={1},value={2},requiredFields={3} - CALLED!", context, component, value, Arrays.toString(requiredFields))); //NOI18N + //this.getLogger().logTrace(MessageFormat.format("preValidate: context={0},component={1},value={2},requiredFields={3} - CALLED!", context, component, value, Arrays.toString(requiredFields))); //NOI18N // Pre-validate super.preValidate(context, component, value, requiredFields); @@ -50,7 +49,7 @@ public abstract class BaseBooleanValidator extends BaseObjectValidator implement // So far all fine, no check if the field is fine for (final String field : requiredFields) { // Debug message - this.getLogger().logDebug(MessageFormat.format("preValidate: field={0},clientId={1}", field, clientId)); //NOI18N + //this.getLogger().logDebug(MessageFormat.format("preValidate: field={0},clientId={1}", field, clientId)); //NOI18N // Is it the same? if (clientId.endsWith(field)) { diff --git a/src/org/mxchange/jcoreee/validator/bool/privacy_terms/PrivacyTermsCheckboxValidator.java b/src/org/mxchange/jcoreee/validator/bool/privacy_terms/PrivacyTermsCheckboxValidator.java index 68fbd8c..f47b597 100644 --- a/src/org/mxchange/jcoreee/validator/bool/privacy_terms/PrivacyTermsCheckboxValidator.java +++ b/src/org/mxchange/jcoreee/validator/bool/privacy_terms/PrivacyTermsCheckboxValidator.java @@ -16,7 +16,6 @@ */ 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; @@ -26,14 +25,14 @@ import org.mxchange.jcoreee.validator.bool.BaseBooleanValidator; /** * A validator for privacy and terms checkboxes * - * @author Roland Haeder + * @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().logTrace(MessageFormat.format("validate: context={0},component={1},value={2} - CALLED!", context, component, value)); //NOI18N + //this.getLogger().logTrace(MessageFormat.format("validate: context={0},component={1},value={2} - CALLED!", context, component, value)); //NOI18N // All accepted, required fields String[] requiredFileds = {"privacy", "terms"}; //NOI18N @@ -42,6 +41,6 @@ public class PrivacyTermsCheckboxValidator extends BaseBooleanValidator implemen super.preValidate(context, component, value, requiredFileds); // Trace message - this.getLogger().logTrace("validate: EXIT!"); //NOI18N + //this.getLogger().logTrace("validate: EXIT!"); //NOI18N } } diff --git a/src/org/mxchange/jcoreee/validator/string/BaseStringValidator.java b/src/org/mxchange/jcoreee/validator/string/BaseStringValidator.java index 2075353..34203b5 100644 --- a/src/org/mxchange/jcoreee/validator/string/BaseStringValidator.java +++ b/src/org/mxchange/jcoreee/validator/string/BaseStringValidator.java @@ -16,8 +16,6 @@ */ 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; @@ -28,14 +26,14 @@ 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 + * @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().logTrace(MessageFormat.format("preValidate: context={0},component={1},value={2},fields={3} - CALLED!", context, component, value, Arrays.toString(requiredFields))); //NOI18N + //this.getLogger().logTrace(MessageFormat.format("preValidate: 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); @@ -48,7 +46,7 @@ public abstract class BaseStringValidator extends BaseObjectValidator { // So far all fine, no check if the field is fine for (final String field : requiredFields) { // Debug message - this.getLogger().logDebug(MessageFormat.format("preValidate: field={0},clientId={1}", field, clientId)); //NOI18N + //this.getLogger().logDebug(MessageFormat.format("preValidate: field={0},clientId={1}", field, clientId)); //NOI18N // Is it the same? if (clientId.endsWith(field)) { @@ -74,14 +72,13 @@ public abstract class BaseStringValidator extends BaseObjectValidator { } // Debug message - this.getLogger().logDebug(MessageFormat.format("preValidate: facesMessage={0}", facesMessage)); //NOI18N - + //this.getLogger().logDebug(MessageFormat.format("preValidate: facesMessage={0}", facesMessage)); //NOI18N // Is it not null? if (null != facesMessage) { throw new ValidatorException(facesMessage); } // Trace message - this.getLogger().logTrace("preValidate: EXIT!"); //NOI18N + //this.getLogger().logTrace("preValidate: EXIT!"); //NOI18N } } diff --git a/src/org/mxchange/jcoreee/validator/string/names/NameValidator.java b/src/org/mxchange/jcoreee/validator/string/names/NameValidator.java index a59caa2..f76f61a 100644 --- a/src/org/mxchange/jcoreee/validator/string/names/NameValidator.java +++ b/src/org/mxchange/jcoreee/validator/string/names/NameValidator.java @@ -13,10 +13,9 @@ * * 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; @@ -26,13 +25,14 @@ import org.mxchange.jcoreee.validator.string.BaseStringValidator; /** * A validation class for names, such as first name or family name. * - * @author Roland Haeder + * @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().logTrace(MessageFormat.format("validate: context={0},component={1},value={2} - CALLED!", context, component, value)); //NOI18N + //this.getLogger().logTrace(MessageFormat.format("validate: context={0},component={1},value={2} - CALLED!", context, component, value)); //NOI18N // All accepted, required fields String[] requiredFileds = {"firstName", "familyName", "city", "street"}; //NOI18N @@ -41,6 +41,6 @@ public class NameValidator extends BaseStringValidator implements Validator { super.preValidate(context, component, value, requiredFileds); // Trace message - this.getLogger().logTrace("validate: EXIT!"); //NOI18N + //this.getLogger().logTrace("validate: EXIT!"); //NOI18N } } -- 2.39.5