Package org.apache.wicket.validation

Examples of org.apache.wicket.validation.ValidationError


            public void validate(final IValidatable<T> validatable) {
                final T proposed = validatable.getValue();
                final ObjectAdapter proposedAdapter = adapterFor(proposed);
                String reasonIfAny = scalarModel.validate(proposedAdapter);
                if (reasonIfAny != null) {
                    final ValidationError error = new ValidationError();
                    error.setMessage(reasonIfAny);
                    validatable.error(error);
                }
            }
        });
    }
View Full Code Here


            @Override
            public void validate(final IValidatable<ObjectAdapter> validatable) {
                final ObjectAdapter proposedAdapter = validatable.getValue();
                final String reasonIfAny = getModel().validate(proposedAdapter);
                if (reasonIfAny != null) {
                    final ValidationError error = new ValidationError();
                    error.setMessage(reasonIfAny);
                    validatable.error(error);
                }
            }
        });
View Full Code Here

            final DateTimeField dateTimeField = (DateTimeField) dateTimeComponents[0];

            if (!(dateTimeField.getDate() != null && dateTimeField.getHours() != null
                    && dateTimeField.getMinutes() != null)) {

                ValidationError ve = new ValidationError();
                ve.setVariables(DateTimeFormValidator.this.variablesMap());
                ve.addKey(resourceKey());
                dateTimeComponents[0].error((IValidationError) ve);
            }
        }
View Full Code Here

    {
      throw new IllegalArgumentException("Argument [[resourceKey]] cannot be null");
    }


    ValidationError error = new ValidationError().addMessageKey(resourceKey);
    final String defaultKey = Classes.simpleName(getClass());
    if (!resourceKey.equals(defaultKey))
    {
      error.addMessageKey(defaultKey);
    }

    error.setVariables(vars);
    validatable.error(error);
  }
View Full Code Here

  public void validate(IValidatable<Z> validatable)
  {
    Z value = validatable.getValue();
    if (value.compareTo(minimum) < 0 || value.compareTo(maximum) > 0)
    {
      ValidationError error = new ValidationError();
      error.addMessageKey("RangeValidator");
      error.setVariable("minimum", minimum);
      error.setVariable("maximum", maximum);
      validatable.error(error);
    }
  }
View Full Code Here

    {
      throw new IllegalArgumentException("Argument [[resourceKey]] cannot be null");
    }


    ValidationError error = new ValidationError().addMessageKey(resourceKey);
    final String defaultKey = Classes.simpleName(getClass());
    if (!resourceKey.equals(defaultKey))
    {
      error.addMessageKey(defaultKey);
    }

    error.setVariables(vars);
    validatable.error(error);
  }
View Full Code Here

      {
        convertedInput = convertValue(getInputAsArray());
      }
      catch (ConversionException e)
      {
        ValidationError error = new ValidationError();
        if (e.getResourceKey() != null)
        {
          error.addKey(e.getResourceKey());
        }
        if (e.getTargetType() != null)
        {
          error.addKey("ConversionError." + Classes.simpleName(e.getTargetType()));
        }
        error.addKey("ConversionError");
        reportValidationError(e, error);
      }
    }
    else
    {
      final IConverter<T> converter = getConverter(getType());

      try
      {
        convertedInput = converter.convertToObject(getInput(), getLocale());
      }
      catch (ConversionException e)
      {
        ValidationError error = new ValidationError();
        if (e.getResourceKey() != null)
        {
          error.addKey(e.getResourceKey());
        }
        String simpleName = Classes.simpleName(getType());
        error.addKey("IConverter." + simpleName);
        error.addKey("IConverter");
        error.setVariable("type", simpleName);
        reportValidationError(e, error);
      }
    }
  }
View Full Code Here

  /**
   * Reports required error against this component
   */
  private void reportRequiredError()
  {
    error(new ValidationError().addKey("Required"));
  }
View Full Code Here

  public void validate(IValidatable<Z> validatable)
  {
    Z value = validatable.getValue();
    if (value.compareTo(minimum) < 0 || value.compareTo(maximum) > 0)
    {
      ValidationError error = new ValidationError();
      error.addMessageKey("RangeValidator");
      error.setVariable("minimum", minimum);
      error.setVariable("maximum", maximum);
      validatable.error(error);
    }
  }
View Full Code Here

    {
      throw new IllegalArgumentException("Argument [[resourceKey]] cannot be null");
    }


    ValidationError error = new ValidationError().addMessageKey(resourceKey);
    final String defaultKey = Classes.simpleName(getClass());
    if (!resourceKey.equals(defaultKey))
    {
      error.addMessageKey(defaultKey);
    }

    error.setVariables(vars);
    validatable.error(error);
  }
View Full Code Here

TOP

Related Classes of org.apache.wicket.validation.ValidationError

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.