Examples of ValidationError


Examples of org.apache.wicket.validation.ValidationError

   *            the original cause
   * @return {@link ValidationError}
   */
  protected ValidationError newValidationError(ConversionException cause)
  {
    ValidationError error = new ValidationError(cause.getMessage());

    if (cause.getResourceKey() != null)
    {
      error.addKey(cause.getResourceKey());
    }

    if (typeName == null)
    {
      if (cause.getTargetType() != null)
      {
        error.addKey("ConversionError." + Classes.simpleName(cause.getTargetType()));
      }
      error.addKey("ConversionError");
    }
    else
    {
      String simpleName = Classes.simpleName(getType());
      error.addKey("IConverter." + simpleName);
      error.addKey("IConverter");
      error.setVariable("type", simpleName);
    }

    final Locale locale = cause.getLocale();
    if (locale != null)
    {
      error.setVariable("locale", locale);
    }

    error.setVariable("exception", cause);

    Format format = cause.getFormat();
    if (format instanceof SimpleDateFormat)
    {
      error.setVariable("format", ((SimpleDateFormat)format).toLocalizedPattern());
    }

    Map<String, Object> variables = cause.getVariables();
    if (variables != null)
    {
      error.getVariables().putAll(variables);
    }

    return error;
  }
View Full Code Here

Examples of org.apache.wicket.validation.ValidationError

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

Examples of org.apache.wicket.validation.ValidationError

  {
    Args.notNull(fc, "fc");
    Args.notNull(vars, "vars");
    Args.notNull(resourceKey, "resourceKey");

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

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

Examples of org.apache.wicket.validation.ValidationError

      {
        convertedInput = convertValue(getInputAsArray());
      }
      catch (ConversionException e)
      {
        ValidationError error = new ValidationError();
        if (e.getResourceKey() != null)
        {
          error.addMessageKey(e.getResourceKey());
        }
        if (e.getTargetType() != null)
        {
          error.addMessageKey("ConversionError." + Classes.simpleName(e.getTargetType()));
        }
        error.addMessageKey("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.addMessageKey(e.getResourceKey());
        }
        String simpleName = Classes.simpleName(getType());
        error.addMessageKey("IConverter." + simpleName);
        error.addMessageKey("IConverter");
        error.setVariable("type", simpleName);
        reportValidationError(e, error);
      }
    }
  }
View Full Code Here

Examples of org.apache.wicket.validation.ValidationError

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

Examples of org.apache.wicket.validation.ValidationError

    Z value = validatable.getValue();
    final Z min = getMinimum();
    final Z max = getMaximum();
    if (value.compareTo(min) < 0 || value.compareTo(max) > 0)
    {
      ValidationError error = new ValidationError();
      error.addMessageKey("RangeValidator");
      error.setVariable("minimum", min);
      error.setVariable("maximum", max);
      validatable.error(error);
    }
  }
View Full Code Here

Examples of org.apache.wicket.validation.ValidationError

          String rolesInput = rolesChoiceField.getInput();
          if (rolesInput != null && (!"".equals(rolesInput)))
          {
            if ("".equals(rolesSetNameField.getInput()))
            {
              rolesSetNameField.error((IValidationError)new ValidationError().addMessageKey("error.noSetNameForRoles"));
            }
          }
        }
      });
    }
View Full Code Here

Examples of org.apache.wicket.validation.ValidationError

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

Examples of org.apache.wicket.validation.ValidationError

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


    ValidationError error = new ValidationError().addKey(resourceKey);
    final String defaultKey = getClass().getSimpleName();
    if (!resourceKey.equals(defaultKey))
    {
      error.addKey(defaultKey);
    }

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

Examples of org.apache.wicket.validation.ValidationError

      {
        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." + e.getTargetType().getSimpleName());
        }
        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 = getType().getSimpleName();
        error.addKey("IConverter." + simpleName);
        error.addKey("IConverter");
        error.setVariable("type", simpleName);
        reportValidationError(e, error);
      }
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.