Package org.hdiv.validation

Examples of org.hdiv.validation.ValidationError


   * javax.faces.component.UIComponent)
   */
  public ValidationError validate(FacesContext context, UIComponent component) {

    UIForm form = (UIForm) component;
    ValidationError error = this.validateEditablesForm(context, form);
    return error;
  }
View Full Code Here


   * @param formComponent
   *            UIForm component to validate
   * @return result
   */
  protected ValidationError validateEditablesForm(FacesContext context, UIForm formComponent) {
    ValidationError error = null;

    for (UIComponent component : formComponent.getChildren()) {
      ValidationError tempError = this.validateComponent(context, component);
      if (tempError != null) {
        error = tempError;
      }
    }
    return error;
View Full Code Here

    if ((uiComponent instanceof HtmlInputText) || (uiComponent instanceof HtmlInputTextarea)
        || (uiComponent instanceof HtmlInputSecret) || (uiComponent instanceof HtmlInputHidden)) {
      UIInput inputComponent = (UIInput) uiComponent;
      return validateInput(context, inputComponent);
    } else {
      ValidationError error = null;
      for (UIComponent child : uiComponent.getChildren()) {
        ValidationError tempError = validateComponent(context, child);
        if (tempError != null) {
          error = tempError;
        }
      }
      return error;
View Full Code Here

      FacesMessage msg = this.createFacesMessage(context, inputComponent);
      context.addMessage(clientId, msg);

      inputComponent.setValid(false);

      return new ValidationError(HDIVErrorCodes.EDITABLE_VALIDATION_ERROR, null, clientId, value.toString());
    }
    return null;
  }
View Full Code Here

   * javax.faces.component.UIComponent)
   */
  public ValidationError validate(FacesContext context, UIComponent component) {

    HtmlInputHiddenExtension inputHidden = (HtmlInputHiddenExtension) component;
    ValidationError error = this.validateHiddenComponent(context, inputHidden);

    return error;
  }
View Full Code Here

        log.debug("Hidden's value received:" + hiddenValue);
        log.debug("Hidden's value sent to the client:" + hiddenRealValue);
      }

      if (hiddenValue == null) {
        ValidationError error = new ValidationError();
        error.setErrorKey(HDIVErrorCodes.REQUIRED_PARAMETERS);
        error.setErrorParam(inputHidden.getId());
        error.setErrorValue("null");
        error.setErrorComponent(inputHidden.getClientId(context));
        return error;
      }

      boolean correcto = this.hasEqualValue(hiddenValue, hiddenRealValue);
      if (!correcto) {
        ValidationError error = new ValidationError();
        error.setErrorKey(HDIVErrorCodes.PARAMETER_VALUE_INCORRECT);
        error.setErrorParam(inputHidden.getId());
        error.setErrorValue(hiddenRealValue.toString());
        error.setErrorComponent(inputHidden.getClientId(context));
        return error;
      }
    } else {
      // else, actual position isn't a table, but hidden is in a table
      // and its clientId is incorrect
      List<String> clientIds = inputHidden.getClientIds();
      for (int i = 0; i < clientIds.size(); i++) {
        String clientId = clientIds.get(i);
        hiddenValue = request.getParameter(clientId);
        hiddenRealValue = inputHidden.getRealValue(clientId);
        if (log.isDebugEnabled()) {
          log.debug("Hidden's value received:" + hiddenValue);
          log.debug("Hidden's value sent to the client:" + hiddenRealValue);
        }

        if (hiddenValue == null) {
          ValidationError error = new ValidationError();
          error.setErrorKey(HDIVErrorCodes.REQUIRED_PARAMETERS);
          error.setErrorParam(inputHidden.getId());
          error.setErrorValue("null");
          error.setErrorComponent(inputHidden.getClientId(context));
          return error;
        }

        boolean correcto = hiddenValue.equals(hiddenRealValue);
        if (!correcto) {
          ValidationError error = new ValidationError();
          error.setErrorKey(HDIVErrorCodes.PARAMETER_VALUE_INCORRECT);
          error.setErrorParam(inputHidden.getId());
          error.setErrorValue(hiddenRealValue.toString());
          error.setErrorComponent(inputHidden.getClientId(context));
          return error;
        }
      }

    }
View Full Code Here

    // Check CommandLink's parameters
    for (UIComponent childComp : component.getChildren()) {
      if (childComp instanceof UIParameter) {
        UIParameter param = (UIParameter) childComp;
        ValidationError error = this.processParam(context, param, rowIndex);
        if (error != null) {
          return error;
        }
      }
    }
View Full Code Here

      log.debug("requestValue:" + requestValue);
      log.debug("realValue:" + realValue);
    }

    if (requestValue == null) {
      ValidationError error = new ValidationError();
      error.setErrorKey(HDIVErrorCodes.REQUIRED_PARAMETERS);
      error.setErrorParam(param.getId());
      error.setErrorValue(requestValue);
      error.setErrorComponent(param.getClientId(context));
      return error;

    }
    if (!requestValue.equals(realValue)) {
      ValidationError error = new ValidationError();
      error.setErrorKey(HDIVErrorCodes.PARAMETER_VALUE_INCORRECT);
      error.setErrorParam(param.getId());
      error.setErrorValue(requestValue);
      error.setErrorComponent(param.getClientId(context));
      return error;
    }
    return null;
  }
View Full Code Here

   * javax.faces.component.UIComponent)
   */
  public ValidationError validate(FacesContext context, UIComponent component) {

    UIForm form = (UIForm) component;
    ValidationError error = this.validateRequestParameters(context, form);

    return error;
  }
View Full Code Here

    List<String> clientIds = this.getClientIds(context, formComponent);

    boolean validParameter = true;
    boolean validParameters = true;

    ValidationError error = null;

    Map<String, String> requestParameters = context.getExternalContext().getRequestParameterMap();
    for (Entry<String, String> entry : requestParameters.entrySet()) {
      String requestParamName = entry.getKey().toString().trim();
      if (UtilsJsf.isFacesViewParamName(requestParamName)) {
        continue;
      }

      // Row identifier is removed from parameter name if it is inside
      // a datatable
      String requestParamNameWithRowId = requestParamName;
      requestParamName = UtilsJsf.removeRowId(requestParamName);

      // In MyFaces, some clientId of tables contain a rowId
      validParameter = ((clientIds.contains(requestParamName)) || (clientIds.contains(requestParamNameWithRowId)));
      if (!validParameter) {

        // It may be a parameter added in the client, for instance
        // using JavaScript.
        // In this case check if it is a userStartParameters

        boolean isStartParam = this.hdivConfig.isStartParameter(requestParamName);
        if (isStartParam) {
          if (log.isDebugEnabled()) {
            log.debug("Parameter '" + requestParamName + "' is a startParameter");
          }
          validParameter = true;
        } else {
          // It is not a startParameter, non expected parameter
          // raise error
          validParameter = false;

          Object value = requestParameters.get(requestParamName);
          String paramValue = "";
          if (value != null) {
            paramValue = value.toString();
          }
          error = new ValidationError(HDIVErrorCodes.PARAMETER_NOT_EXISTS, null, requestParamName, paramValue);
        }
      }
      validParameters = validParameters && validParameter;
    }
    return error;
View Full Code Here

TOP

Related Classes of org.hdiv.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.