Class FormDef.Input

java.lang.Object
org.apache.juneau.console.widgets.FormDef.Input
Enclosing class:
FormDef

@BeanType(properties="name,label,type,required,value,options,pattern,maxLength,help,actionId") public static class FormDef.Input extends Object
A single typed form input painted client-side with createElement (never innerHTML).
Since:
10.0.0
  • Field Details

    • name

      public String name
      The submit-body key for this field (e.g. resolution).
    • label

      public String label
      The label shown next to the control.
    • type

      public String type
      One of text, textarea, password, checkbox, toggle, select, action.
    • required

      public Boolean required
      When Boolean.TRUE, the control is required. Omitted from the wire otherwise.
    • value

      public String value
      Optional prefill, applied via .value / .checked (never innerHTML).
    • options

      The options for a select field, in display order; omitted from the wire otherwise.
    • pattern

      public String pattern
      An optional client validation regexp for text/textarea; omitted from the wire otherwise.
    • maxLength

      An optional client max-length for text/textarea; omitted from the wire otherwise.
    • help

      public String help
      An optional help hint painted with textContent; omitted from the wire otherwise.
    • actionId

      public String actionId
      The enclosing view's row-action id an action button opens; omitted from the wire otherwise. See ActionRef for the typed reference the builder accepts.
  • Constructor Details

  • Method Details

    • of

      public static FormDef.Input of(String name, String label, String type)
      Creates a typed form input.
      Parameters:
      name - The submit-body key (also the DOM identity for an action field). Must not be null or blank.
      label - The visible label. Must not be null or blank.
      type - One of text, textarea, password, checkbox, toggle, select, action. null or blank defaults to text.
      Returns:
      A new FormDef.Input.
      Throws:
      IllegalArgumentException - If name or label is blank, or type is not an allowed token.
    • required

      Marks this input required.
      Returns:
      This object.
    • required

      public FormDef.Input required(boolean value)
      Sets whether this input is required.
      Parameters:
      value - true to require a value; false omits the flag from the wire.
      Returns:
      This object.
    • value

      public FormDef.Input value(String value)
      Sets the optional prefill.
      Parameters:
      value - The prefill. Can be null to unset.
      Returns:
      This object.
    • options

      Sets the select options (replacing any existing).
      Parameters:
      value - The options. Must not be null.
      Returns:
      This object.
      Throws:
      IllegalArgumentException - If value is null or contains a null entry.
    • option

      public FormDef.Input option(String value, String label)
      Adds one select option.
      Parameters:
      value - The submit value. Must not be null.
      label - The visible option text. Must not be null or blank.
      Returns:
      This object.
      Throws:
      IllegalArgumentException - If value is null or label is blank.
    • pattern

      public FormDef.Input pattern(String value)
      Sets the client validation regexp (text/textarea only).
      Parameters:
      value - The pattern. Can be null to unset.
      Returns:
      This object.
    • maxLength

      public FormDef.Input maxLength(int value)
      Sets the client max-length (text/textarea only).
      Parameters:
      value - The max length. Must be > 0.
      Returns:
      This object.
    • help

      public FormDef.Input help(String value)
      Sets the help hint (painted with textContent).
      Parameters:
      value - The hint. Can be null to unset.
      Returns:
      This object.
    • actionId

      public FormDef.Input actionId(String value)
      Sets the enclosing view's row-action id this action button opens.
      Parameters:
      value - The action id. Can be null to unset.
      Returns:
      This object.
    • action

      public FormDef.Input action(ActionRef value)
      Sets the action target from an ActionRef (stores ActionRef.id).
      Parameters:
      value - The action reference. Must not be null.
      Returns:
      This object.
      Throws:
      IllegalArgumentException - If value is null.