/**
*
- * @author Roland Haeder
+ * @author Roland Haeder<roland@mxchange.org>
*/
public class BaseEeSystem {
/**
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<roland@mxchange.org>
*/
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.
*/
}
/**
- * 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);
}
}
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<roland@mxchange.org>
*/
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
*/
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;
// 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)) {
}
// 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
}
// 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
}
}
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;
* A general boolean value validator.
*
* @author BalusC
- * @author Roland Haeder
+ * @author Roland Haeder<roland@mxchange.org>
*/
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);
// 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)) {
*/
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;
/**
* A validator for privacy and terms checkboxes
*
- * @author Roland Haeder
+ * @author Roland Haeder<roland@mxchange.org>
*/
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
super.preValidate(context, component, value, requiredFileds);
// Trace message
- this.getLogger().logTrace("validate: EXIT!"); //NOI18N
+ //this.getLogger().logTrace("validate: EXIT!"); //NOI18N
}
}
*/
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;
* 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<roland@mxchange.org>
*/
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);
// 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)) {
}
// 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
}
}
*
* 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.jcoreee.validator.string.names;
-import java.text.MessageFormat;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.Validator;
/**
* A validation class for names, such as first name or family name.
*
- * @author Roland Haeder
+ * @author Roland Haeder<roland@mxchange.org>
*/
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
super.preValidate(context, component, value, requiredFileds);
// Trace message
- this.getLogger().logTrace("validate: EXIT!"); //NOI18N
+ //this.getLogger().logTrace("validate: EXIT!"); //NOI18N
}
}