Package de.odysseus.calyxo.forms

Examples of de.odysseus.calyxo.forms.FormInput


    if (this.inputs != null) {
      VariableResolver resolver = new CalyxoVariableResolver(request);
      Iterator inputs = getFormInputs();
      while (inputs.hasNext()) {
        FormInput input = (FormInput)inputs.next();
        if (input.isIgnored(resolver)) {
          result.add(new IgnoredFormInputResult(input, params));
        } else {
          result.add(input.validate(request, params, resolver));
        }
      }
    }

    if (asserts != null) {
View Full Code Here


  /**
   * Add input result
   */
  void add(FormInputResult value) {
    FormInput input = value.getFormInput();
    values.put(input.getName(), value);
    if (!value.isValid() && !value.isIgnored()) {
      invalid = true;
      if (!value.isRelaxed()) {
        messages.addMessage(input.getName(), value.getFirstMessage());
        if (input.isArray()) {
          Iterator iter = value.getLastMessages();
          while (iter.hasNext()) {
            messages.addMessage(input.getName(), (Message)iter.next());
          }
        }
      }
    }
  }
View Full Code Here

    if (assertFailedNames == null) {
      assertFailedNames = new HashSet();
    }
    Iterator involved = resolver.getInvolvedFormInputs();
    while (involved.hasNext()) {
      FormInput input = (FormInput)involved.next();
      assertFailedNames.add(input.getName());
    }
    messages.addGlobalMessage(message);
  }
View Full Code Here

          FormInputResult result =
            formResult.getFormInputResult(name);
          if (result == null) {
            throw new NoSuchElementException("Bad input name: " + name);
          }
          FormInput input = result.getFormInput();
          involvedInputs.add(input);
          if (input.isArray()) {
            return inputValues._getInputs(name);
          } else {
            return inputValues._getInput(name);
          }
        }
View Full Code Here

          if (field == null) {
            throw new NoSuchElementException("Bad property name: " + key);
          }
          FormInputResult result =
            formResult.getFormInputResult(field.getName());
          FormInput input = result.getFormInput();
          involvedInputs.add(input);
          if (!result.isValid()) {
            invalidPropertyReferenced = true;
            return null;
          }
View Full Code Here

  /**
   * Check if the specified component corresponds to an input in this form.
   */
  public void check(FormComponent component) throws ConfigException {
    FormInput input = form.getFormInput(component.getName());
    if (input == null) {
      throw new ConfigException("Input '" + component.getName() + "' does not exist!");
    }
    if (!input.isArray() && component.getIndex() >= 0) {
      throw new ConfigException("Input '" + component.getName() + "' is not an array, but has an index!");
    }
  }
View Full Code Here

 
  /**
   * Get value for specified component.
   */
  public String getInputValue(FormComponent component) throws Exception {
    FormInput input = form.getFormInput(component.getName());
    if (input.isArray()) {
      int index = component.getIndex();
      if (index < 0) {
        throw new ConfigException("Input '" + component.getName() + "' has no index");
      }
      if (result != null) {
        FormInputResult inputResult = result.getFormInputResult(component.getName());
        if (index >= inputResult.getSize()) {
          return NOT_AVAILABLE;
        }
        return inputResult.format(request, index);
      } else if (data != null) {
        return input.format(request, data, index, NOT_AVAILABLE);
      }
    } else {
      if (result != null) {
        return (String)result.getFormInputResult(component.getName()).format(request);
      } else if (data != null) {
        return (String)input.format(request, data);
      }
    }
    return NOT_AVAILABLE;
  }
View Full Code Here

  /**
   * Get value array for specified component.
   */
  public String[] getInputValues(FormComponent component) throws Exception {
    FormInput input = form.getFormInput(component.getName());
    if (!input.isArray()) {
      throw new ConfigException("Input '" + component.getName() + "' is not an array");
    }
    if (result != null) {
      return (String[])result.getFormInputResult(component.getName()).format(request);
    } else if (data != null) {
      return (String[])input.format(request, data);
    } else {
      return NOT_AVAILABLE_ARRAY;
    }
  }
View Full Code Here

      if (result != null) {
        try {
          Iterator inputs = result.getFormInputResults();
          while (inputs.hasNext()) {
            FormInputResult inputResult = (FormInputResult)inputs.next();
            FormInput input = inputResult.getFormInput();
            Object value = inputResult.format(request);
            if (input.isArray()) {
              values._setInputs(input.getName(), (String[])value);
            } else {
              values._setInput(input.getName(), (String)value);
            }
          }
        } catch (Exception e) {
          throw new JspException(e);
        }
      } else {
        Form form = support.getForm(request, action);
        if (form == null) {
          throw new JspException("Cannot find form for action '" + action + "'!");
        }
        try {
          Iterator inputs = form.getFormInputs();
          while (inputs.hasNext()) {
            FormInput input = (FormInput)inputs.next();
            Object value = input.format(request, formData);
            if (input.isArray()) {
              values._setInputs(input.getName(), (String[])value);
            } else {
              values._setInput(input.getName(), (String)value);
            }
          }
        } catch (Exception e) {
          throw new JspException(e);
        }
View Full Code Here

TOP

Related Classes of de.odysseus.calyxo.forms.FormInput

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.