FormInterface

public interface FormInterface

Methods

addCheck

void addCheck(CheckInterface check)

Add a validation check.

Parameters:
  • check

addField

void addField(FieldInterface field)

addField

void addField(String colName, View view)

disableCheck

void disableCheck(CheckInterface check)

Disable a validation check

Parameters:
  • check

getErrors

Map<String, List> getErrors()

Returns all the errors on the form after validation.

Returns:the key is the form identifier and the values is a list of all the validation errors related with the form.

getField

FieldInterface getField(String fieldName)

getFields

Map<String, FieldInterface> getFields()

getIdentifier

String getIdentifier()

A unique identifier for this form.

getValidator

ValidatorInterface getValidator()

The validator this form will be using to validate the inner forms.

getValue

Object getValue(String fieldName)

Returns the value a particular field.

The returned values depends on the field some fields the values is a string whilst others its a list of string.

Consult the specific field to get the returned value.

Parameters:
  • fieldName
Throws:

getValues

Map<String, Object> getValues()

Return the values of each field on the form.

The returned values depends on the field some fields the values is a string whilst others its a list of string.

Consult the specific field to get the returned value.

Throws:
Returns:

a map, where keys a field identifier used when adding field to form and values are the fields respective values.

isValid

boolean isValid()

This is the entry point for form validations.

It firsts invokes the validate() to get the form wide validation .

It the tells the validator to run the validation check.

Returns:true only if the validation checks passed.

removeField

void removeField(String replace)

removeField

void removeField(FieldInterface field)

save

void save()

This is where you should put you saving logic.

throw FormException if validation fails.

Throws:

setData

void setData(Map data)

setValue

void setValue(String fieldName, Object value)

Set value for a specific.

Parameters:
  • fieldName – the identifier to use to locate the field being set.
  • value – the value being set, this depends on specific field .consult specific field to find expected value.

validate

void validate()

This is the right place to perform form wide validations. That is validating fields against each other, also validate against parent form fields.

At this point you have access to the getValues() of both parent form and current form you can use this values to compare against.

The recommend approach is to a create check that implements FormAwareInterface and add it to the validator.

This method is invoked before the field specific validations have been run.