Interface FormProvider
-
- All Implemented Interfaces:
public interface FormProvider
Handles all form related operations on the owning document. Retrieve it with getFormProvider.
-
-
Method Summary
Modifier and Type Method Description abstract <T extends FormElementConfiguration> FormField
addFormElementsToPage(@NonNull() String fullyQualifiedName, @NonNull() List<T> formElementConfigurations)
Allows to programmatically create and insert a form field into the document. abstract <T extends FormElementConfiguration> Single<FormField>
addFormElementsToPageAsync(@NonNull() String fullyQualifiedName, @NonNull() List<T> formElementConfigurations)
Allows to programmatically create and insert a form field into the document, asynchronously. abstract <T extends FormElementConfiguration> FormField
addFormElementToPage(@NonNull() String fullyQualifiedName, @NonNull() T formElementConfiguration)
Allows to programmatically create and insert a form field into the document. abstract <T extends FormElementConfiguration> Single<FormField>
addFormElementToPageAsync(@NonNull() String fullyQualifiedName, @NonNull() T formElementConfiguration)
Allows to programmatically create and insert a form field into the document, asynchronously. abstract boolean
removeFormElementFromPage(@NonNull() FormElement formElement)
Allows to programmatically remove a form element from the document. abstract Single<Boolean>
removeFormElementFromPageAsync(@NonNull() FormElement formElement)
Allows to programmatically remove a form element from the document, asynchronously. abstract Single<List<FormField>>
getFormFieldsAsync()
Returns the list of all form fields in the document, asynchronously. abstract List<FormField>
getFormFields()
Returns a list of all form fields in the document. abstract Maybe<FormField>
getFormFieldWithFullyQualifiedNameAsync(@NonNull() String fullyQualifiedName)
Searches for a form field with fully qualified field name, asynchronously. abstract FormField
getFormFieldWithFullyQualifiedName(@NonNull() String fullyQualifiedName)
Searches for a form field with fully qualified field name. abstract Single<List<FormElement>>
getFormElementsAsync()
Returns a list of all form elements in the document, asynchronously. abstract List<FormElement>
getFormElements()
Returns a list of all form elements in the document. abstract Maybe<FormElement>
getFormElementForAnnotationAsync(@NonNull() WidgetAnnotation annotation)
Finds a form element for widget annotation, asynchronously. abstract FormElement
getFormElementForAnnotation(@NonNull() WidgetAnnotation annotation)
Finds a form element for widget annotation. abstract Maybe<FormElement>
getFormElementWithNameAsync(@NonNull() String fieldName)
Searches for a form element with a given name, asynchronously. abstract FormElement
getFormElementWithName(@NonNull() String fieldName)
Searches for a form element by name. abstract Single<List<FormElement>>
getTabOrderAsync()
Returns order of FormElement for document, asynchronously. abstract List<FormElement>
getTabOrder()
Returns order of FormElement for document. abstract void
addOnFormFieldUpdatedListener(@NonNull() FormListeners.OnFormFieldUpdatedListener listener)
Adds OnFormFieldUpdatedListener to get notified when any form field gets updated. abstract void
removeOnFormFieldUpdatedListener(@NonNull() FormListeners.OnFormFieldUpdatedListener listener)
Removes previously registered OnFormFieldUpdatedListener. abstract void
addOnFormTabOrderUpdatedListener(@NonNull() FormListeners.OnFormTabOrderUpdatedListener listener)
Adds OnFormTabOrderUpdatedListener to get notified when form tab order has been recalculated. abstract void
removeOnFormTabOrderUpdatedListener(@NonNull() FormListeners.OnFormTabOrderUpdatedListener listener)
Removes previously registered OnFormTabOrderUpdatedListener. abstract void
addOnTextFormFieldUpdatedListener(@NonNull() FormListeners.OnTextFormFieldUpdatedListener listener)
Adds OnTextFormFieldUpdatedListener to get notified when text fields get updated. abstract void
removeOnTextFormFieldUpdatedListener(@NonNull() FormListeners.OnTextFormFieldUpdatedListener listener)
Removes previously registered OnTextFormFieldUpdatedListener. abstract void
addOnButtonFormFieldUpdatedListener(@NonNull() FormListeners.OnButtonFormFieldUpdatedListener listener)
Adds OnButtonFormFieldUpdatedListener to get notified when button fields get updated. abstract void
removeOnButtonFormFieldUpdatedListener(@NonNull() FormListeners.OnButtonFormFieldUpdatedListener listener)
Removes previously registered OnButtonFormFieldUpdatedListener. abstract void
addOnChoiceFormFieldUpdatedListener(@NonNull() FormListeners.OnChoiceFormFieldUpdatedListener listener)
Adds OnChoiceFormFieldUpdatedListener to get notified when choice fields get updated. abstract void
removeOnChoiceFormFieldUpdatedListener(@NonNull() FormListeners.OnChoiceFormFieldUpdatedListener listener)
Removes previously registered OnChoiceFormFieldUpdatedListener. abstract boolean
hasUnsavedChanges()
Returns whether form fields in this document were modified or not. -
-
Method Detail
-
addFormElementsToPage
@NonNull() abstract <T extends FormElementConfiguration> FormField addFormElementsToPage(@NonNull() String fullyQualifiedName, @NonNull() List<T> formElementConfigurations)
Allows to programmatically create and insert a form field into the document. The newly created form field will be automatically attached to the document once created.
- Parameters:
fullyQualifiedName
- The fully qualified name of the new form field.formElementConfigurations
- List of form element configuration classes (Only and RadioButtonFormConfiguration support multiple elements).- Returns:
The newly created form field.
-
addFormElementsToPageAsync
@NonNull() abstract <T extends FormElementConfiguration> Single<FormField> addFormElementsToPageAsync(@NonNull() String fullyQualifiedName, @NonNull() List<T> formElementConfigurations)
Allows to programmatically create and insert a form field into the document, asynchronously. The newly created form field will be automatically attached to the document once created.
- Parameters:
fullyQualifiedName
- The fully qualified name of the new form field.formElementConfigurations
- List of form element configuration classes (Only and RadioButtonFormConfiguration support multiple elements).- Returns:
Single emitting the newly created form field.
-
addFormElementToPage
@NonNull() abstract <T extends FormElementConfiguration> FormField addFormElementToPage(@NonNull() String fullyQualifiedName, @NonNull() T formElementConfiguration)
Allows to programmatically create and insert a form field into the document.
- Parameters:
fullyQualifiedName
- The fully qualified name of the new form field.formElementConfiguration
- Form element configuration class.- Returns:
The newly created form field.
-
addFormElementToPageAsync
@NonNull() abstract <T extends FormElementConfiguration> Single<FormField> addFormElementToPageAsync(@NonNull() String fullyQualifiedName, @NonNull() T formElementConfiguration)
Allows to programmatically create and insert a form field into the document, asynchronously.
- Parameters:
fullyQualifiedName
- The fully qualified name of the new form field.formElementConfiguration
- Form element configuration class.- Returns:
Single emitting the newly created form field.
-
removeFormElementFromPage
abstract boolean removeFormElementFromPage(@NonNull() FormElement formElement)
Allows to programmatically remove a form element from the document.
- Parameters:
formElement
- The FormElement to remove.- Returns:
true
if the form element was deleted, orfalse
if there was an error.
-
removeFormElementFromPageAsync
@NonNull() abstract Single<Boolean> removeFormElementFromPageAsync(@NonNull() FormElement formElement)
Allows to programmatically remove a form element from the document, asynchronously.
- Parameters:
formElement
- The FormElement to remove.- Returns:
Single emitting
true
if the form element was deleted, orfalse
if there was an error.
-
getFormFieldsAsync
@NonNull() abstract Single<List<FormField>> getFormFieldsAsync()
Returns the list of all form fields in the document, asynchronously.
- Returns:
Single emitting list of form fields in the document.
-
getFormFields
@NonNull() abstract List<FormField> getFormFields()
Returns a list of all form fields in the document.
Note: this call may block for a while and should not be invoked on the main thread.
- Returns:
A list of form fields in the document.
-
getFormFieldWithFullyQualifiedNameAsync
@NonNull() abstract Maybe<FormField> getFormFieldWithFullyQualifiedNameAsync(@NonNull() String fullyQualifiedName)
Searches for a form field with fully qualified field name, asynchronously.
- Parameters:
fullyQualifiedName
- The fully qualified field name.- Returns:
Maybe emitting form field value or just completing.
-
getFormFieldWithFullyQualifiedName
@Nullable() abstract FormField getFormFieldWithFullyQualifiedName(@NonNull() String fullyQualifiedName)
Searches for a form field with fully qualified field name. Returns the first field with given
fullyQualifiedName
.Note: this call may block for a while and should not be invoked on the main thread.
- Parameters:
fullyQualifiedName
- The fully qualified field name.- Returns:
Found form field or null.
-
getFormElementsAsync
@NonNull() abstract Single<List<FormElement>> getFormElementsAsync()
Returns a list of all form elements in the document, asynchronously.
- Returns:
Single emitting list of form elements in the document.
-
getFormElements
@NonNull() abstract List<FormElement> getFormElements()
Returns a list of all form elements in the document.
Note: this call may block for a while and should not be invoked on the main thread.
-
getFormElementForAnnotationAsync
@NonNull() abstract Maybe<FormElement> getFormElementForAnnotationAsync(@NonNull() WidgetAnnotation annotation)
Finds a form element for widget annotation, asynchronously.
- Parameters:
annotation
- Widget annotation to search for.- Returns:
Maybe emitting a FormElement value in `onSuccess()` or just ending with `onComplete()`.
-
getFormElementForAnnotation
@Nullable() abstract FormElement getFormElementForAnnotation(@NonNull() WidgetAnnotation annotation)
Finds a form element for widget annotation.
Note: this call may block for a while and should not be invoked on the main thread.
- Parameters:
annotation
- Widget annotation to search for.- Returns:
A found annotation or null.
-
getFormElementWithNameAsync
@NonNull() abstract Maybe<FormElement> getFormElementWithNameAsync(@NonNull() String fieldName)
Searches for a form element with a given name, asynchronously.
- Parameters:
fieldName
- The form element name.- Returns:
Maybe emitting form element value or just completing.
-
getFormElementWithName
@Nullable() abstract FormElement getFormElementWithName(@NonNull() String fieldName)
Searches for a form element by name. Returns the first element with given
name
.Note: this call may block for a while and should not be invoked on the main thread.
- Parameters:
fieldName
- The form element name.- Returns:
A found form element, or null.
-
getTabOrderAsync
@NonNull() abstract Single<List<FormElement>> getTabOrderAsync()
Returns order of FormElement for document, asynchronously.
- Returns:
Single emitting list of FormElement in tab order.
-
getTabOrder
@NonNull() abstract List<FormElement> getTabOrder()
Returns order of FormElement for document. We calculate the tab order with two different methods:
- A Fallback tab order that is quick to calculate. This will provide reasonable tab ordering but it won't be correct.
- In the background, we start calculating the proper tab order. When this is done, onFormTabOrderUpdated will be called.
- Returns:
List of FormElement in tab order.
-
addOnFormFieldUpdatedListener
abstract void addOnFormFieldUpdatedListener(@NonNull() FormListeners.OnFormFieldUpdatedListener listener)
Adds OnFormFieldUpdatedListener to get notified when any form field gets updated. If the listener has already been added previously, this method will be a no-op. Adding
null
is not allowed, and will result in an exception.- Parameters:
listener
- OnFormFieldUpdatedListener that should be notified.
-
removeOnFormFieldUpdatedListener
abstract void removeOnFormFieldUpdatedListener(@NonNull() FormListeners.OnFormFieldUpdatedListener listener)
Removes previously registered OnFormFieldUpdatedListener. Upon calling this method the
listener
will no longer be notified of any changes. If the listener has not been added, this method will be a no-op. Passingnull
is not allowed, and will result in an exception.- Parameters:
listener
- OnFormFieldUpdatedListener that should be removed.
-
addOnFormTabOrderUpdatedListener
abstract void addOnFormTabOrderUpdatedListener(@NonNull() FormListeners.OnFormTabOrderUpdatedListener listener)
Adds OnFormTabOrderUpdatedListener to get notified when form tab order has been recalculated. If the listener has already been added previously, this method will be a no-op. Adding
null
is not allowed, and will result in an exception.- Parameters:
listener
- OnFormTabOrderUpdatedListener that should be notified.
-
removeOnFormTabOrderUpdatedListener
abstract void removeOnFormTabOrderUpdatedListener(@NonNull() FormListeners.OnFormTabOrderUpdatedListener listener)
Removes previously registered OnFormTabOrderUpdatedListener. Upon calling this method the
listener
will no longer be notified of any changes. If the listener has not been added, this method will be a no-op. Passingnull
is not allowed, and will result in an exception.- Parameters:
listener
- OnFormTabOrderUpdatedListener that should be removed.
-
addOnTextFormFieldUpdatedListener
abstract void addOnTextFormFieldUpdatedListener(@NonNull() FormListeners.OnTextFormFieldUpdatedListener listener)
Adds OnTextFormFieldUpdatedListener to get notified when text fields get updated. If the listener has already been added previously, this method will be a no-op. Adding
null
is not allowed, and will result in an exception.- Parameters:
listener
- OnTextFormFieldUpdatedListener that should be notified.
-
removeOnTextFormFieldUpdatedListener
abstract void removeOnTextFormFieldUpdatedListener(@NonNull() FormListeners.OnTextFormFieldUpdatedListener listener)
Removes previously registered OnTextFormFieldUpdatedListener. Upon calling this method the
listener
will no longer be notified of any changes. If the listener has not been added, this method will be a no-op. Passingnull
is not allowed, and will result in an exception.- Parameters:
listener
- OnTextFormFieldUpdatedListener that should be removed.
-
addOnButtonFormFieldUpdatedListener
abstract void addOnButtonFormFieldUpdatedListener(@NonNull() FormListeners.OnButtonFormFieldUpdatedListener listener)
Adds OnButtonFormFieldUpdatedListener to get notified when button fields get updated. If the listener has already been added previously, this method will be a no-op. Adding
null
is not allowed, and will result in an exception.- Parameters:
listener
- OnButtonFormFieldUpdatedListener that should be notified.
-
removeOnButtonFormFieldUpdatedListener
abstract void removeOnButtonFormFieldUpdatedListener(@NonNull() FormListeners.OnButtonFormFieldUpdatedListener listener)
Removes previously registered OnButtonFormFieldUpdatedListener. Upon calling this method the
listener
will no longer be notified of any changes. If the listener has not been added, this method will be a no-op. Passingnull
is not allowed, and will result in an exception.- Parameters:
listener
- OnButtonFormFieldUpdatedListener that should be removed.
-
addOnChoiceFormFieldUpdatedListener
abstract void addOnChoiceFormFieldUpdatedListener(@NonNull() FormListeners.OnChoiceFormFieldUpdatedListener listener)
Adds OnChoiceFormFieldUpdatedListener to get notified when choice fields get updated. If the listener has already been added previously, this method will be a no-op. Adding
null
is not allowed, and will result in an exception.- Parameters:
listener
- OnChoiceFormFieldUpdatedListener that should be notified.
-
removeOnChoiceFormFieldUpdatedListener
abstract void removeOnChoiceFormFieldUpdatedListener(@NonNull() FormListeners.OnChoiceFormFieldUpdatedListener listener)
Removes previously registered OnChoiceFormFieldUpdatedListener. Upon calling this method the
listener
will no longer be notified of any changes. If the listener has not been added, this method will be a no-op. Passingnull
is not allowed, and will result in an exception.- Parameters:
listener
- OnChoiceFormFieldUpdatedListener that should be removed.
-
hasUnsavedChanges
abstract boolean hasUnsavedChanges()
Returns whether form fields in this document were modified or not.
- Returns:
true
if form fields in this document were modified and the document should be saved, orfalse
if no forms were modified.
-
-
-
-