Package org.apache.wicket.validation

Examples of org.apache.wicket.validation.ValidationError


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

    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


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

      {
        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

  /**
   * Reports required error against this component
   */
  private void reportRequiredError()
  {
    error((IValidationError)new ValidationError().addMessageKey("Required"));
  }
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);
    fc.error((IValidationError)error);
  }
View Full Code Here

      {
        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");

        final Locale locale = e.getLocale();
        if (locale != null)
        {
          error.setVariable("locale", locale);
        }
        error.setVariable("exception", e);
        Format format = e.getFormat();
        if (format instanceof SimpleDateFormat)
        {
          error.setVariable("format", ((SimpleDateFormat)format).toLocalizedPattern());
        }

        error((IValidationError)error);
      }
    }
    else
    {
      final IConverter 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);
        final Locale locale = e.getLocale();
        if (locale != null)
        {
          error.setVariable("locale", locale);
        }
        error.setVariable("exception", e);
        Format format = e.getFormat();
        if (format instanceof SimpleDateFormat)
        {
          error.setVariable("format", ((SimpleDateFormat)format).toLocalizedPattern());
        }

        error((IValidationError)error);
      }
    }
View Full Code Here

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

      {
        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 converter = getConverter(getType());

      try
      {
        convertedInput = (T)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

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

      {
        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 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

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.