*
* 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
*
* 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
* 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.
* <p>
* 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.
* <p>
- protected void preValidate (final FacesContext context, final UIComponent component, final Object value, final String[] requiredFields, boolean allowNull) throws ValidatorException {
+ protected void preValidate (final FacesContext context, final UIComponent component, final Object value, final String[] requiredFields, Boolean allowNull) throws ValidatorException {
- //this.getLogger().logTrace(MessageFormat.format("preValidate: context={0},component={1},value={2},fields={3} - CALLED!", context, component, value, Arrays.toString(requiredFields))); //NOI18N
+ //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("preValidate: context={0},component={1},value={2},fields={3} - CALLED!", context, component, value, Arrays.toString(requiredFields))); //NOI18N
// Pre-validate (example: on null)
super.preValidate(context, component, value, requiredFields, allowNull);
// Get client id and init message + key
String clientId = component.getClientId();
// Pre-validate (example: on null)
super.preValidate(context, component, value, requiredFields, allowNull);
// Get client id and init message + key
String clientId = component.getClientId();
// So far all fine, no check if the field is fine
for (final String field : requiredFields) {
// So far all fine, no check if the field is fine
for (final String field : requiredFields) {
- facesMessage = new FacesMessage(MessageFormat.format("Field {0} is not String: {1}", field, value)); //NOI18N
+ requiredMessage = MessageFormat.format("Field {0} is not String: {1}", field, value); //NOI18N
- // Generate message
- facesMessage = new FacesMessage(MessageFormat.format("Field {0} is empty.", field)); //NOI18N
+ // Empty strings are currently not accepted, may indicate flaw in invoker
+ requiredMessage = MessageFormat.format("Field {0} is empty.", field); //NOI18N
- if (null != facesMessage) {
- throw new ValidatorException(facesMessage);
+ if (null != requiredMessage) {
+ // Then there was something wrong with it
+ throw new ValidatorException(new FacesMessage(requiredMessage));