org.jreform.internal
Class GroupImpl

java.lang.Object
  extended by org.jreform.internal.AbstractInputCollection
      extended by org.jreform.internal.GroupImpl
All Implemented Interfaces:
Group, HttpServletRequestValidator, InputCollection

 class GroupImpl
extends AbstractInputCollection
implements Group

An input group maintains its own set of inputs and errors and has its own validation rules. The rules depend on whether the group isRequired().

  • If required: all inputs must satisfy imposed criteria for the group to be deemed valid.
  • Otherwise: either all inputs in this group are empty (have no values) for the group to be valid OR all inputs satisfy imposed criteria.

    Author:
    armandino (at) gmail.com

    Field Summary
    private  boolean isEmpty
               
    private  boolean isRequired
               
    private  String name
               
    private  AbstractForm parent
               
     
    Constructor Summary
    GroupImpl(AbstractForm parent, String name, boolean isRequired)
              Create a new input group.
     
    Method Summary
    <T> void
    add(InputControl<T> input)
              Adds the input to this input group and its parent form.
    private  boolean containsInputData(javax.servlet.http.HttpServletRequest req)
               
     String getName()
              Returns the name of this group.
     boolean isEmpty()
              Checks if this group has input data.
     boolean isRequired()
              If required all inputs must satisfy imposed criteria for the group to be valid.
     void setRequired(boolean isRequired)
              Set whether this group is required.
     boolean validate(javax.servlet.http.HttpServletRequest req)
              Validates the passed in HttpServletRequest.
    (package private)  void validateInputs(javax.servlet.http.HttpServletRequest req)
               
     
    Methods inherited from class org.jreform.internal.AbstractInputCollection
    addError, additionalValidate, checkbox, getCheckbox, getErrors, getInput, getInputControl, getInputs, getInputValue, getMultiCheckbox, getMultiInputValue, getMultiSelect, getRadio, getSelect, input, isValid, multiCheckbox, multiSelect, radio, select, setValid, toString
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
     
    Methods inherited from interface org.jreform.Group
    isValid
     
    Methods inherited from interface org.jreform.InputCollection
    checkbox, getCheckbox, getInput, getInputValue, getMultiCheckbox, getMultiInputValue, getMultiSelect, getRadio, getSelect, input, multiCheckbox, multiSelect, radio, select
     
    Methods inherited from interface org.jreform.HttpServletRequestValidator
    getErrors
     

    Field Detail

    parent

    private AbstractForm parent

    name

    private String name

    isRequired

    private boolean isRequired

    isEmpty

    private boolean isEmpty
    Constructor Detail

    GroupImpl

    GroupImpl(AbstractForm parent,
              String name,
              boolean isRequired)
    Create a new input group.

    Parameters:
    parent - to which this group will belong.
    name - of the group.
    isRequired - if this group should be treated as valid when empty.
    Method Detail

    add

    public final <T> void add(InputControl<T> input)
    Adds the input to this input group and its parent form.

    Overrides:
    add in class AbstractInputCollection

    getName

    public final String getName()
    Description copied from interface: Group
    Returns the name of this group.

    Specified by:
    getName in interface Group

    isRequired

    public final boolean isRequired()
    Description copied from interface: Group
    If required all inputs must satisfy imposed criteria for the group to be valid. If optional either all inputs must be null OR all inputs must satisfy their criteria for the group to be valid.

    Specified by:
    isRequired in interface Group

    isEmpty

    public final boolean isEmpty()
    Description copied from interface: Group
    Checks if this group has input data.

    Specified by:
    isEmpty in interface Group
    Returns:
    true if all inputs that belong to this group are blank, false otherwise.

    setRequired

    public void setRequired(boolean isRequired)
    Description copied from interface: Group
    Set whether this group is required.

    Specified by:
    setRequired in interface Group

    validate

    public final boolean validate(javax.servlet.http.HttpServletRequest req)
    Description copied from interface: HttpServletRequestValidator
    Validates the passed in HttpServletRequest.

    Specified by:
    validate in interface HttpServletRequestValidator

    validateInputs

    final void validateInputs(javax.servlet.http.HttpServletRequest req)

    containsInputData

    private boolean containsInputData(javax.servlet.http.HttpServletRequest req)


    Copyright © 2007-2008 jReform