Interface FormActionApi

All Superinterfaces:
FormInputBuilderApi

public interface FormActionApi extends FormInputBuilderApi
The FormActionApi is exposed to form logics through the form binding during the action phase.

This phase is triggered when a user changes the value of an input. The logic can react by updating other inputs (e.g., setting values, labels, read-only state), inserting new inputs, or modifying the layout.

Extends FormInputBuilderApi so that input builder methods (e.g. create*) are available for creating inputs to pass to insertAfter(String, ContextParameter...).

Since:
17.0 - Paloma
  • Method Details

    • sourceInputName

      String sourceInputName()
      Returns the name of the input that triggered the current form execution. This is typically the input whose value changed.

      Example:

      
           if (form.sourceInputName() == "country") {
               form.updateInput("city").setValue(null)
           }
       
      Returns:
      The name of the source input.
      Since:
      17.0 - Paloma
    • updateInput

      FormChange updateInput(String inputName)
      Returns a FormChange object for the specified input, allowing modification of its properties such as value, label, read-only state, or validity. If no FormChange exists yet for the given input name, a new one is created. Subsequent calls with the same input name return the same instance.

      Example:

      
           form.updateInput("total")
               .setValue(form.input.quantity * form.input.price)
               .setReadOnly(true)
       
      Parameters:
      inputName - The name of the input to update. Must not be null.
      Returns:
      A FormChange instance for the specified input.
      Throws:
      NullPointerException - if inputName is null.
      Since:
      17.0 - Paloma
    • insertAfter

      FormChange insertAfter(String inputName, ContextParameter... inputsToAdd)
      Inserts one or more new input definitions after the specified existing input. This allows dynamically adding inputs to the form during action mode execution. Multiple calls for the same input name accumulate the inputs to be inserted.

      Example:

      
           def newInput = form.createStringUserEntry("notes")
               .setLabel("Notes")
               .buildFormInput()
      
           form.insertAfter("quantity", newInput)
       
      Parameters:
      inputName - The name of the existing input after which new inputs will be inserted. Must not be null.
      inputsToAdd - The input definitions to insert as ContextParameter instances.
      Returns:
      A FormChange instance for the specified input, with the new inputs queued for insertion.
      Throws:
      NullPointerException - if inputName is null.
      Since:
      17.0 - Paloma