public class FormComponentsGroup extends BaseFormComponent<android.view.View,Void>
FormComponents into one group which can be validated.
There is only one difference between group of all components within FormValidator and
group of components here. If during validation process there is found an invalid component
(FormComponent.validate() of one of group components returns false), validation
of such group stops and no next form components from that group are validated.
Invalid form component for the current validation process can be obtained via getInvalidComponent().
This can be useful, when there are components in form, where some of them depends on each other
and if some of these dependent components is invalid, there is no need to check next ones.
| Constructor and Description |
|---|
FormComponentsGroup(int id)
Creates a new instance of FormComponentsGroup to
|
| Modifier and Type | Method and Description |
|---|---|
FormComponentsGroup |
addComponent(FormComponent component)
Adds the given form component into this group.
|
FormComponentsGroup |
addComponents(FormComponent... components)
Adds the given form components into this group.
|
void |
attachToValidator(FormValidator validator)
Attaches this form component to the given validator.
|
void |
clearError()
Clears the current errors of all components within this group.
|
protected FormComponent |
findComponentTraversal(int id)
Will search within the current form components to find a one with the requested id.
|
FormComponent |
getComponent(int componentId)
Returns an instance of FormComponent with the requested id.
|
android.util.SparseArray<FormComponent> |
getComponents()
Returns all components from this group.
|
Void |
getInput()
Always returns
null, as a group of form components does not have a specific view attached
thus it cannot have any input also. |
FormComponent |
getInvalidComponent()
Returns currently invalid form component.
|
android.view.View |
getView()
Always returns
null, as a group of form components does not have a specific view attached. |
boolean |
hasInputChanged()
Checks whether the current value of this form component has changed since its last validation.
|
static boolean |
isGroup(FormComponent component)
Checks whether the given component represents group of form components or not.
|
protected boolean |
onValidate(Void input)
Invoked whenever
BaseFormComponent.validate() is called. |
void |
setError(CharSequence errorMessage)
This implementation does nothing.
|
boolean |
validate()
Runs validation process of this form component.
|
findComponent, getId, getLastValidatedInput, getResources, getValidator, hasError, isAttachedToValidator, obtainString, obtainText, onAttachedToValidator, onComponentViewAttached, resetCurrentState, setHasErrorpublic FormComponentsGroup(int id)
id - The id representing this group of form components.public static boolean isGroup(FormComponent component)
component - An instance of form component to check for group.True if the given component is group, false otherwise.public void attachToValidator(FormValidator validator)
FormComponentattachToValidator in interface FormComponent<android.view.View,Void>attachToValidator in class BaseFormComponent<android.view.View,Void>validator - An instance of FormValidator with which is this form component associated.public boolean hasInputChanged()
FormComponent
Basically, whenever this returns true this component should be validated, otherwise
there is no need given the fact that its value did not change.
hasInputChanged in interface FormComponent<android.view.View,Void>hasInputChanged in class BaseFormComponent<android.view.View,Void>True if the current value is different from the one that has been last time
validated via FormComponent.validate(), false otherwise.public boolean validate()
FormComponentvalidate in interface FormComponent<android.view.View,Void>validate in class BaseFormComponent<android.view.View,Void>True if the current state of this form component's view is valid,
false otherwise.protected boolean onValidate(Void input)
BaseFormComponentBaseFormComponent.validate() is called. Note, that there will be BaseFormComponent.resetCurrentState()
always called before this.onValidate in class BaseFormComponent<android.view.View,Void>input - Current input of this form component to be validated.true if the current form component's view state passed
validation requirements, false otherwise.FormComponent.getInput()public FormComponentsGroup addComponents(FormComponent... components)
FormComponentsGroup class description
for info about how group of form components behave during validation.components - Form components which should be part of this group.public FormComponentsGroup addComponent(FormComponent component)
FormComponentsGroup class description
for info about how group of form components behave during validation.component - Form component which should be part of this group.public android.view.View getView()
null, as a group of form components does not have a specific view attached.getView in interface FormComponent<android.view.View,Void>getView in class BaseFormComponent<android.view.View,Void>public Void getInput()
null, as a group of form components does not have a specific view attached
thus it cannot have any input also.public android.util.SparseArray<FormComponent> getComponents()
public FormComponent getComponent(int componentId)
BaseFormComponent.findComponent(int),
this will check only at the top of the current components hierarchy.componentId - Id of the desired form component to obtain.null if there
is no such a form component presented within this group.public FormComponent getInvalidComponent()
false from BaseFormComponent.validate()
during the last validation process, or null if there was no validation requested
upon this group yet, or the last validation was successful.public void setError(CharSequence errorMessage)
errorMessage - The desired error message.FormComponent.clearError()public void clearError()
clearError in interface FormComponent<android.view.View,Void>clearError in class BaseFormComponent<android.view.View,Void>protected FormComponent findComponentTraversal(int id)
findComponentTraversal in class BaseFormComponent<android.view.View,Void>id - Id of the desired component to find.null if
this group does not contain form component with such an id.