* @param component UIComponent instance
* @param value Value to check
* @param requiredFields Array of required field names (ending with)
+ * @param allowNull Wether null or empty values are allowed
* <p>
* @throws ValidatorException If something more horrible went wrong
*/
- protected void preValidate (final FacesContext context, final UIComponent component, final Object value, final String[] requiredFields) throws ValidatorException {
+ protected void preValidate (final FacesContext context, final UIComponent component, final Object value, final String[] requiredFields, boolean allowNull) 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
isValidField = true;
// Is it null?
- if (null == value) {
+ if ((!allowNull) && (null == value)) {
// Value it null
facesMessage = new FacesMessage(MessageFormat.format("Field {0} is null.", field)); //NOI18N
}
private static final long serialVersionUID = 42_378_178_715_910_689L;
@Override
- public void preValidate (final FacesContext context, final UIComponent component, final Object value, final String[] requiredFields) throws ValidatorException {
+ public void preValidate (final FacesContext context, final UIComponent component, final Object value, final String[] requiredFields, boolean allowNull) 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
// Pre-validate
- super.preValidate(context, component, value, requiredFields);
+ super.preValidate(context, component, value, requiredFields, allowNull);
// Get client id and init message + key
String clientId = component.getClientId();
String[] requiredFileds = {"privacy", "terms"}; //NOI18N
// Pre-validation (example: not null, not a string, empty string ...)
- super.preValidate(context, component, value, requiredFileds);
+ super.preValidate(context, component, value, requiredFileds, false);
// Trace message
//this.getLogger().logTrace("validate: EXIT!"); //NOI18N
private static final long serialVersionUID = 25_481_878_590_589_321L;
@Override
- public void preValidate (final FacesContext context, final UIComponent component, final Object value, final String[] requiredFields) throws ValidatorException {
+ public void preValidate (final FacesContext context, final UIComponent component, final Object value, final String[] requiredFields, boolean allowNull) 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
// Pre-validate
- super.preValidate(context, component, value, requiredFields);
+ super.preValidate(context, component, value, requiredFields, allowNull);
// Get client id and init message + key
String clientId = component.getClientId();
String[] requiredFileds = {"amount"}; //NOI18N
// Pre-validation (example: not null, not a string, empty string ...)
- super.preValidate(context, component, value, requiredFileds);
+ super.preValidate(context, component, value, requiredFileds, false);
// Trace message
//this.getLogger().logTrace("validate: EXIT!"); //NOI18N
private static final long serialVersionUID = 15_484_578_781_760_287L;
@Override
- protected void preValidate (final FacesContext context, final UIComponent component, final Object value, final String[] requiredFields) throws ValidatorException {
+ protected void preValidate (final FacesContext context, final UIComponent component, final Object value, final String[] requiredFields, boolean allowNull) 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
// Pre-validate (example: on null)
- super.preValidate(context, component, value, requiredFields);
+ super.preValidate(context, component, value, requiredFields, allowNull);
// Get client id and init message + key
String clientId = component.getClientId();
String[] requiredFileds = {"firstName", "familyName", "city", "street"}; //NOI18N
// Pre-validation (example: not null, not a string, empty string ...)
- super.preValidate(context, component, value, requiredFileds);
+ super.preValidate(context, component, value, requiredFileds, true);
// Trace message
//this.getLogger().logTrace("validate: EXIT!"); //NOI18N