public interface

FormProvider

com.pspdfkit.forms.FormProvider

Class Overview

Handles all form related operations on the owning document. Retrieve it with getFormProvider().

Summary

Public Methods
abstract <T extends FormElementConfiguration> FormField addFormElementToPage(String fullyQualifiedName, T formElementConfiguration)
Allows to programmatically create and insert a form field into the document.
abstract <T extends FormElementConfiguration> Single<FormField> addFormElementToPageAsync(String fullyQualifiedName, T formElementConfiguration)
Allows to programmatically create and insert a form field into the document, asynchronously.
abstract <T extends FormElementConfiguration> FormField addFormElementsToPage(String fullyQualifiedName, List<T> formElementConfigurations)
Allows to programmatically create and insert a form field into the document.
abstract <T extends FormElementConfiguration> Single<FormField> addFormElementsToPageAsync(String fullyQualifiedName, List<T> formElementConfigurations)
Allows to programmatically create and insert a form field into the document, asynchronously.
abstract void addOnButtonFormFieldUpdatedListener(FormListeners.OnButtonFormFieldUpdatedListener listener)
Adds FormListeners.OnButtonFormFieldUpdatedListener to get notified when button fields get updated.
abstract void addOnChoiceFormFieldUpdatedListener(FormListeners.OnChoiceFormFieldUpdatedListener listener)
Adds FormListeners.OnChoiceFormFieldUpdatedListener to get notified when choice fields get updated.
abstract void addOnFormFieldUpdatedListener(FormListeners.OnFormFieldUpdatedListener listener)
Adds FormListeners.OnFormFieldUpdatedListener to get notified when any form field gets updated.
abstract void addOnFormTabOrderUpdatedListener(FormListeners.OnFormTabOrderUpdatedListener listener)
Adds FormListeners.OnFormTabOrderUpdatedListener to get notified when form tab order has been recalculated.
abstract void addOnTextFormFieldUpdatedListener(FormListeners.OnTextFormFieldUpdatedListener listener)
Adds FormListeners.OnTextFormFieldUpdatedListener to get notified when text fields get updated.
abstract FormElement getFormElementForAnnotation(WidgetAnnotation annotation)
Finds a form element for widget annotation.
abstract Maybe<FormElement> getFormElementForAnnotationAsync(WidgetAnnotation annotation)
Finds a form element for widget annotation, asynchronously.
abstract FormElement getFormElementWithName(String fieldName)
Searches for a form element by name.
abstract Maybe<FormElement> getFormElementWithNameAsync(String fieldName)
Searches for a form element with a given name, asynchronously.
abstract List<FormElement> getFormElements()
Returns a list of all form elements in the document.
abstract Single<List<FormElement>> getFormElementsAsync()
Returns a list of all form elements in the document, asynchronously.
abstract FormField getFormFieldWithFullyQualifiedName(String fullyQualifiedName)
Searches for a form field with fully qualified field name.
abstract Maybe<FormField> getFormFieldWithFullyQualifiedNameAsync(String fullyQualifiedName)
Searches for a form field with fully qualified field name, asynchronously.
abstract List<FormField> getFormFields()
Returns a list of all form fields in the document.
abstract Single<List<FormField>> getFormFieldsAsync()
Returns the list of all form fields in the document, asynchronously.
abstract List<FormElement> getTabOrder()
Returns order of FormElement for document.
abstract Single<List<FormElement>> getTabOrderAsync()
Returns order of FormElement for document, asynchronously.
abstract boolean hasUnsavedChanges()
Returns whether form fields in this document were modified or not.
abstract boolean removeFormElementFromPage(FormElement formElement)
Allows to programmatically remove a form element from the document.
abstract Single<Boolean> removeFormElementFromPageAsync(FormElement formElement)
Allows to programmatically remove a form element from the document, asynchronously.
abstract void removeOnButtonFormFieldUpdatedListener(FormListeners.OnButtonFormFieldUpdatedListener listener)
Removes previously registered FormListeners.OnButtonFormFieldUpdatedListener.
abstract void removeOnChoiceFormFieldUpdatedListener(FormListeners.OnChoiceFormFieldUpdatedListener listener)
Removes previously registered FormListeners.OnChoiceFormFieldUpdatedListener.
abstract void removeOnFormFieldUpdatedListener(FormListeners.OnFormFieldUpdatedListener listener)
Removes previously registered FormListeners.OnFormFieldUpdatedListener.
abstract void removeOnFormTabOrderUpdatedListener(FormListeners.OnFormTabOrderUpdatedListener listener)
Removes previously registered FormListeners.OnFormTabOrderUpdatedListener.
abstract void removeOnTextFormFieldUpdatedListener(FormListeners.OnTextFormFieldUpdatedListener listener)
Removes previously registered FormListeners.OnTextFormFieldUpdatedListener.

Public Methods

public abstract FormField addFormElementToPage (String fullyQualifiedName, 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.

public abstract Single<FormField> addFormElementToPageAsync (String fullyQualifiedName, 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.

public abstract FormField addFormElementsToPage (String fullyQualifiedName, 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 CheckBoxFormConfiguration and RadioButtonFormConfiguration support multiple elements).
Returns
  • The newly created form field.

public abstract Single<FormField> addFormElementsToPageAsync (String fullyQualifiedName, 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 CheckBoxFormConfiguration and RadioButtonFormConfiguration support multiple elements).
Returns
  • Single emitting the newly created form field.

public abstract void addOnButtonFormFieldUpdatedListener (FormListeners.OnButtonFormFieldUpdatedListener listener)

Adds FormListeners.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 FormListeners.OnButtonFormFieldUpdatedListener that should be notified. Must be non-null.

public abstract void addOnChoiceFormFieldUpdatedListener (FormListeners.OnChoiceFormFieldUpdatedListener listener)

Adds FormListeners.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 FormListeners.OnChoiceFormFieldUpdatedListener that should be notified. Must be non-null.

public abstract void addOnFormFieldUpdatedListener (FormListeners.OnFormFieldUpdatedListener listener)

Adds FormListeners.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 FormListeners.OnFormFieldUpdatedListener that should be notified. Must be non-null.

public abstract void addOnFormTabOrderUpdatedListener (FormListeners.OnFormTabOrderUpdatedListener listener)

Adds FormListeners.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 FormListeners.OnFormTabOrderUpdatedListener that should be notified. Must be non-null.

public abstract void addOnTextFormFieldUpdatedListener (FormListeners.OnTextFormFieldUpdatedListener listener)

Adds FormListeners.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 FormListeners.OnTextFormFieldUpdatedListener that should be notified. Must be non-null.

public abstract FormElement getFormElementForAnnotation (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.

public abstract Maybe<FormElement> getFormElementForAnnotationAsync (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()`.

public abstract FormElement getFormElementWithName (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.

public abstract Maybe<FormElement> getFormElementWithNameAsync (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.

public 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.

public 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.

public abstract FormField getFormFieldWithFullyQualifiedName (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.

public abstract Maybe<FormField> getFormFieldWithFullyQualifiedNameAsync (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.

public 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.

public 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.

public abstract List<FormElement> getTabOrder ()

Returns order of FormElement for document. We calculate the tab order with two different methods:

  1. A Fallback tab order that is quick to calculate. This will provide reasonable tab ordering but it won't be correct.
  2. In the background, we start calculating the proper tab order. When this is done, onFormTabOrderUpdated() will be called.

p>Note: this call may block for a while and should not be invoked on the main thread.

Returns

public abstract Single<List<FormElement>> getTabOrderAsync ()

Returns order of FormElement for document, asynchronously.

Returns

public 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, or false if no forms were modified.

public abstract boolean removeFormElementFromPage (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, or false if there was an error.

public abstract Single<Boolean> removeFormElementFromPageAsync (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, or false if there was an error.

public abstract void removeOnButtonFormFieldUpdatedListener (FormListeners.OnButtonFormFieldUpdatedListener listener)

Removes previously registered FormListeners.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. Passing null is not allowed, and will result in an exception.

Parameters
listener FormListeners.OnButtonFormFieldUpdatedListener that should be removed. Must be non-null.

public abstract void removeOnChoiceFormFieldUpdatedListener (FormListeners.OnChoiceFormFieldUpdatedListener listener)

Removes previously registered FormListeners.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. Passing null is not allowed, and will result in an exception.

Parameters
listener FormListeners.OnChoiceFormFieldUpdatedListener that should be removed. Must be non-null.

public abstract void removeOnFormFieldUpdatedListener (FormListeners.OnFormFieldUpdatedListener listener)

Removes previously registered FormListeners.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. Passing null is not allowed, and will result in an exception.

Parameters
listener FormListeners.OnFormFieldUpdatedListener that should be removed. Must be non-null.

public abstract void removeOnFormTabOrderUpdatedListener (FormListeners.OnFormTabOrderUpdatedListener listener)

Removes previously registered FormListeners.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 FormListeners.OnFormTabOrderUpdatedListener that should be removed. Must be non-null.

public abstract void removeOnTextFormFieldUpdatedListener (FormListeners.OnTextFormFieldUpdatedListener listener)

Removes previously registered FormListeners.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. Passing null is not allowed, and will result in an exception.

Parameters
listener FormListeners.OnTextFormFieldUpdatedListener that should be removed. Must be non-null.