Package org.apache.wicket.validation

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


    {
      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

            }
        }
        if (sb.length() > 0) {
            String message = "The following resources already exist on the same namespace: "
                    + sb.toString();
            validatable.error(new ValidationError().setMessage(message));
        }
    }
View Full Code Here

        WorkspaceInfo workspace = (WorkspaceInfo) wsComponent.getConvertedInput();
        String name = (String) nameComponent.getConvertedInput();
       
        if(name == null) {
            ValidationError error = new ValidationError();
            error.addMessageKey("StoreNameValidator.storeNameRequired");
            nameComponent.error((IValidationError) error);
            return;
        }

        Catalog catalog = GeoServerApplication.get().getCatalog();

        final StoreInfo existing = catalog.getStoreByName(workspace, name, StoreInfo.class);
        if (existing != null) {
            final String existingId = existing.getId();
            if (!existingId.equals(edittingStoreId)) {
                ValidationError error = new ValidationError();
                error.addMessageKey("StoreNameValidator.storeExistsInWorkspace");
                error.setVariable("workspace", workspace.getName());
                error.setVariable("storeName", name);
                nameComponent.error((IValidationError) error);
            }
        }
    }
View Full Code Here

   *            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

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

    public void validate(IValidatable<List<FileUpload>> validatable)
    {
      if (validatable.getValue() instanceof List == false)
      {
        validatable.error(new ValidationError().addMessageKey("validatable value type not expected"));
      }
      FileUpload upload = validatable.getValue().get(0);
      if (!upload.getClientFileName().contains(TEST_FILE_NAME))
      {
        validatable.error(new ValidationError().addMessageKey("uploaded file name not expected"));
      }
      File tmpFile = null;
      try
      {
        tmpFile = writeTestFile(1);
        if (!new String(read(tmpFile)).equals(new String(upload.getBytes())))
        {
          validatable.error(new ValidationError().addMessageKey("uploaded content not expected"));
        }
      }
      catch (IOException e)
      {
        throw new RuntimeException(e);
View Full Code Here

    Z value = validatable.getValue();
    final Z min = getMinimum();
    final Z max = getMaximum();
    if ((min != null && value.compareTo(min) < 0) || (max != null && 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

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

  public void validate(IValidatable<Z> validatable)
  {
    Z value = validatable.getValue();
    if (value.compareTo(minimum) < 0)
    {
      ValidationError error = new ValidationError();
      error.addMessageKey("MinimumValidator");
      error.setVariable("minimum", minimum);
      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.