public class FormEditable extends BaseFormComponent<android.widget.EditText,CharSequence>
BaseFormComponent implementation that wraps form editable view like EditText
into component that can be validated by FormValidator when
validating a form in which is such a view presented.FormCheckable| Modifier and Type | Field and Description |
|---|---|
static String |
NOT_EMPTY_REG_EXP
Regular expression to check for not empty text.
|
| Constructor and Description |
|---|
FormEditable(android.widget.EditText editable)
Same as
FormEditable(EditText, String) with NOT_EMPTY_REG_EXP for regExp
parameter. |
FormEditable(android.widget.EditText editable,
int regExpResId)
Same as
FormEditable(EditText, String) for regular expression resource id. |
FormEditable(android.widget.EditText editable,
String regExp)
Creates a new instance of FormEditable component for the given editable view with
the specified regular expression.
|
FormEditable(int id)
Same as
FormEditable(int, String) with NOT_EMPTY_REG_EXP for regExp
parameter. |
FormEditable(int id,
int regExpResId)
Creates a new instance of FormEditable component for an editable view with the specified
id.
|
FormEditable(int id,
String regExp)
Creates a new instance of FormEditable component for an editable view with the specified
id and the specified regular expression.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearError()
Clears the current error (if any) of this form component specified via
FormComponent.setError(CharSequence). |
android.text.Editable |
getEditableInput()
Returns the current editable value of the attached text field view.
|
CharSequence |
getInput()
Returns the current input presented by an attached view of this form component.
|
boolean |
hasInputChanged()
Checks whether the current value of this form component has changed since its last validation.
|
protected void |
onAttachedToValidator(FormValidator validator)
Invoked whenever this form component is assigned to the passed validator.
|
protected boolean |
onValidate(CharSequence input)
Invoked whenever
BaseFormComponent.validate() is called. |
void |
setError(CharSequence errorMessage)
Sets an error for this form component.
|
attachToValidator, findComponent, findComponentTraversal, getId, getLastValidatedInput, getResources, getValidator, getView, hasError, isAttachedToValidator, obtainString, obtainText, onComponentViewAttached, resetCurrentState, setHasError, validatepublic static final String NOT_EMPTY_REG_EXP
public FormEditable(int id)
FormEditable(int, String) with NOT_EMPTY_REG_EXP for regExp
parameter.public FormEditable(int id,
String regExp)
id - Id used to find the editable view within the form view hierarchy of
the associated FormValidator via FormValidator.findViewById(int).regExp - The desired regular expression that is used to validate editable
value obtained from the editable view during the validation process.public FormEditable(int id,
int regExpResId)
id - Id used to find the editable view within the form view hierarchy of
the associated FormValidator via FormValidator.findViewById(int).regExpResId - Resource id of the desired regular expression that is used to validate editable
value obtained from the editable view during the validation process.public FormEditable(android.widget.EditText editable)
FormEditable(EditText, String) with NOT_EMPTY_REG_EXP for regExp
parameter.public FormEditable(android.widget.EditText editable,
int regExpResId)
FormEditable(EditText, String) for regular expression resource id.regExpResId - Resource id of the desired regular expression.public FormEditable(android.widget.EditText editable,
String regExp)
editable - Editable view, which should be validated.regExp - The desired regular expression used to validate editable value obtained from
the editable view during the validation process.BaseFormComponent.BaseFormComponent(int, View)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.widget.EditText,CharSequence>hasInputChanged in class BaseFormComponent<android.widget.EditText,CharSequence>True if the current value is different from the one that has been last time
validated via FormComponent.validate(), false otherwise.protected boolean onValidate(CharSequence input)
BaseFormComponentBaseFormComponent.validate() is called. Note, that there will be BaseFormComponent.resetCurrentState()
always called before this.onValidate in class BaseFormComponent<android.widget.EditText,CharSequence>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 CharSequence getInput()
FormComponentpublic android.text.Editable getEditableInput()
null if view of this component is null.public void setError(CharSequence errorMessage)
FormComponentNote, that a specific implementations can ignore this call and also depends on the specific implementation how the requested error parameter will be shown.
errorMessage - The desired error message.FormComponent.clearError()public void clearError()
FormComponentFormComponent.setError(CharSequence).clearError in interface FormComponent<android.widget.EditText,CharSequence>clearError in class BaseFormComponent<android.widget.EditText,CharSequence>protected void onAttachedToValidator(FormValidator validator)
BaseFormComponentonAttachedToValidator in class BaseFormComponent<android.widget.EditText,CharSequence>validator - An instance of FormValidator to which was this form component newly assigned.