*/
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();
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)) {
// 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));
}
// Debug message
- this.getLogger().debug("isValidField=" + isValidField);
+ this.getLogger().debug(MessageFormat.format("isValidField={0}", isValidField)); //NOI18N
// Valid field?
if (!isValidField) {
}
// 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) {
}
// Trace message
- this.getLogger().trace("EXIT!");
+ this.getLogger().trace("EXIT!"); //NOI18N
}
}
-/*\r
- * Copyright (C) 2015 Roland Haeder\r
- *\r
- * This program is free software: you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation, either version 3 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program. If not, see <http://www.gnu.org/licenses/>.\r
- */\r
-package org.mxchange.jsfcore.validator.string;\r
-\r
-import java.text.MessageFormat;\r
-import java.util.Arrays;\r
-import javax.faces.application.FacesMessage;\r
-import javax.faces.component.UIComponent;\r
-import javax.faces.context.FacesContext;\r
-import javax.faces.validator.ValidatorException;\r
-import org.mxchange.jsfcore.validator.BaseObjectValidator;\r
-\r
-/**\r
- * A general string validation class. You normally want to inherit from this\r
- * class for many form fields, e.g. surname, street name, city name and such.\r
- *\r
- * @author Roland Haeder\r
- */\r
-public abstract class BaseStringValidator extends BaseObjectValidator {\r
-\r
- /**\r
- * Pre-validation of value, e.g. not null\r
- *\r
- * @param context FacesContext instance\r
- * @param component UIComponent instance\r
- * @param value Value to check\r
- * @param requiredFields Array of required field names (ending with)\r
- * @throws ValidatorException If something more horrible went wrong\r
- */\r
- @Override\r
- protected void preValidate (final FacesContext context, final UIComponent component, final Object value, final String[] requiredFields) throws ValidatorException {\r
- // Trace message\r
- this.getLogger().trace(MessageFormat.format("context={0},component={1},value={2},fields={3} - CALLED!", context, component, value, Arrays.toString(requiredFields)));\r
-\r
- // Pre-validate (e.g. on null)\r
- super.preValidate(context, component, value, requiredFields);\r
-\r
- // Get client id and init message + key\r
- String clientId = component.getClientId();\r
- FacesMessage facesMessage = null;\r
- String errKey;\r
-\r
- // So far all fine!\r
- for (final String field : requiredFields) {\r
- // Debug message\r
- this.getLogger().debug(MessageFormat.format("field={0},clientId={1}", field, clientId));\r
-\r
- // Is it the same?\r
- if (clientId.endsWith(field)) {\r
- if (!(value instanceof String)) {\r
- // Value is empty\r
- errKey = String.format("error.%s.is_not_string", field);\r
-\r
- facesMessage = new FacesMessage(this.getMessageStringFromKey(errKey));\r
- }\r
-\r
- // Cast to string\r
- String str = (String) value;\r
-\r
- // Is it empty?\r
- if (str.isEmpty()) {\r
- // Value is empty\r
- errKey = String.format("error.%s.is_empty", field);\r
-\r
- facesMessage = new FacesMessage(this.getMessageStringFromKey(errKey));\r
- }\r
- }\r
- }\r
-\r
- // Debug message\r
- this.getLogger().debug(MessageFormat.format("facesMessage={0}", facesMessage));\r
-\r
- // Is it not null?\r
- if (null != facesMessage) {\r
- throw new ValidatorException(facesMessage);\r
- }\r
-\r
- // Trace message\r
- this.getLogger().trace("EXIT!");\r
- }\r
-}\r
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.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
+ }
+}
-/*\r
- * Copyright (C) 2015 Roland Haeder\r
- *\r
- * This program is free software: you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation, either version 3 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program. If not, see <http://www.gnu.org/licenses/>.\r
- */\r
-package org.mxchange.jsfcore.validator.string.names;\r
-\r
-import java.text.MessageFormat;\r
-import javax.faces.component.UIComponent;\r
-import javax.faces.context.FacesContext;\r
-import javax.faces.validator.Validator;\r
-import javax.faces.validator.ValidatorException;\r
-import org.mxchange.jsfcore.validator.string.BaseStringValidator;\r
-\r
-/**\r
- * A validation class for names, such as first name or family name.\r
- *\r
- * @author Roland Haeder\r
- */\r
-public class NameValidator extends BaseStringValidator implements Validator {\r
- @Override\r
- public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException {\r
- // Trace message\r
- this.getLogger().trace(MessageFormat.format("context={0},component={1},value={2} - CALLED!", context, component, value));\r
-\r
- // All accepted, required fields\r
- String[] requiredFileds = {"firstName", "familyName"};\r
-\r
- // Pre-validation (e.g. not null, not a string, empty string ...)\r
- super.preValidate(context, component, value, requiredFileds);\r
-\r
- // Trace message\r
- this.getLogger().trace("EXIT!");\r
- }\r
-}\r
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.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
+ }
+}