Class Textarea


@Marshalled(typeName="textarea") public class Textarea extends HtmlElementRawText<Textarea>
DTO for an HTML <textarea> element.

The textarea element represents a multiline text input control. It allows users to enter and edit text over multiple lines, making it suitable for longer text content such as comments, descriptions, or messages. The textarea element supports various attributes for controlling its size, behavior, and validation.

Examples:

import static org.apache.juneau.bean.html5.HtmlBuilder.*; // Basic textarea Textarea basic = textarea("comments") .rows(4) .cols(50); // Textarea with placeholder and validation Textarea validated = textarea("description") .placeholder("Enter a description...") .required(true) .minlength(10) .maxlength(500); // Textarea with initial content Textarea withContent = textarea("message") .text("Default message text"); // Textarea with styling and behavior Textarea styled = textarea("feedback") .class_("large-textarea") .rows(6) .cols(60) .placeholder("Please provide your feedback...") .wrap("hard"); // Disabled textarea Textarea disabled = textarea("readonly") .disabled(true) .text("This textarea is disabled"); // Textarea with form association Textarea external = new Textarea() .name="external" .form="myForm" .placeholder="This textarea is outside the form";

The following convenience methods are provided for constructing instances of this bean:

See Also:
  • Constructor Details

  • Method Details

    • autocomplete

      public Textarea autocomplete(String value)
      autocomplete attribute.

      Specifies whether the browser should automatically complete the form field based on user's previous input.

      Possible values:

      • "on" - Allow autocomplete (default)
      • "off" - Disable autocomplete
      • "name" - Autocomplete for name fields
      • "email" - Autocomplete for email fields
      • "username" - Autocomplete for username fields
      • "current-password" - Autocomplete for current password
      • "new-password" - Autocomplete for new password
      Parameters:
      value - Autocomplete behavior for the form field. Can be null to unset the attribute.
      Returns:
      This object.
    • autofocus

      public Textarea autofocus(Object value)
      autofocus attribute.

      Automatically focus the form control when the page is loaded.

      Parameters:
      value - The new value for this attribute. Typically a Boolean or String. Can be null to unset the attribute.
      Returns:
      This object.
    • cols

      public Textarea cols(Object value)
      cols attribute.

      Specifies the visible width of the textarea in characters. This is a hint for the browser and may not be exactly followed depending on the font and styling.

      Parameters:
      value - The visible width of the textarea in characters. Can be null to unset the attribute.
      Returns:
      This object.
    • dirname

      public Textarea dirname(String value)
      dirname attribute.

      Specifies the name of a hidden form field that will be submitted along with the textarea value, containing the text direction (ltr or rtl) of the textarea content.

      This is useful for forms that need to preserve text direction information when submitted. The hidden field will contain either "ltr" or "rtl" based on the textarea's direction.

      Parameters:
      value - The name of the hidden field for directionality information. Can be null to unset the attribute.
      Returns:
      This object.
    • disabled

      public Textarea disabled(Object value)
      disabled attribute.

      Whether the form control is disabled.

      This attribute uses deminimized values:

      • false - Attribute is not added
      • true - Attribute is added as "disabled"
      • Other values - Passed through as-is
      Parameters:
      value - The new value for this attribute. Typically a Boolean or String. Can be null to unset the attribute.
      Returns:
      This object.
    • form

      public Textarea form(String value)
      form attribute.

      Associates the textarea with a form element by specifying the form's ID. This allows the textarea to be placed outside the form element while still being part of the form submission.

      The value should match the ID of a form element in the same document.

      Parameters:
      value - The ID of the form element to associate with this textarea. Can be null to unset the attribute.
      Returns:
      This object.
    • inputmode

      public Textarea inputmode(String value)
      inputmode attribute.

      Provides a hint to browsers about the type of virtual keyboard to display on mobile devices.

      Possible values:

      • "none" - No virtual keyboard
      • "text" - Standard text keyboard (default)
      • "tel" - Telephone number keyboard
      • "url" - URL keyboard with .com key
      • "email" - Email keyboard with @ key
      • "numeric" - Numeric keyboard
      • "decimal" - Decimal number keyboard
      • "search" - Search keyboard
      Parameters:
      value - The type of virtual keyboard to display. Can be null to unset the attribute.
      Returns:
      This object.
    • maxlength

      public Textarea maxlength(Object value)
      maxlength attribute.

      Maximum length of value.

      Parameters:
      value - The new value for this attribute. Typically a Number or String. Can be null to unset the attribute.
      Returns:
      This object.
    • minlength

      public Textarea minlength(Object value)
      minlength attribute.

      Minimum length of value.

      Parameters:
      value - The new value for this attribute. Typically a Number or String. Can be null to unset the attribute.
      Returns:
      This object.
    • name

      public Textarea name(String value)
      name attribute.

      Specifies the name of the form control. This name is used when the form is submitted and can be used to access the element via the form.elements API.

      The name should be unique within the form and should not contain spaces or special characters.

      Parameters:
      value - The name of the form control for submission and API access. Can be null to unset the attribute.
      Returns:
      This object.
    • placeholder

      public Textarea placeholder(String value)
      placeholder attribute.

      Provides a hint to the user about what to enter in the textarea. The placeholder text is displayed when the textarea is empty and disappears when the user starts typing.

      The placeholder should be a brief, helpful description of the expected input.

      Parameters:
      value - The placeholder text to display when the textarea is empty. Can be null to unset the attribute.
      Returns:
      This object.
    • readonly

      public Textarea readonly(Object value)
      readonly attribute.

      Whether to allow the value to be edited by the user.

      Parameters:
      value - The new value for this attribute. Typically a Boolean or String. Can be null to unset the attribute.
      Returns:
      This object.
    • required

      public Textarea required(Object value)
      required attribute.

      Whether the control is required for form submission.

      Parameters:
      value - The new value for this attribute. Typically a Boolean or String. Can be null to unset the attribute.
      Returns:
      This object.
    • rows

      public Textarea rows(Number value)
      rows attribute.

      Specifies the visible height of the textarea in lines. This is a hint for the browser and may not be exactly followed depending on the font and styling.

      Parameters:
      value - The visible height of the textarea in lines. Can be null to unset the attribute.
      Returns:
      This object.
    • wrap

      public Textarea wrap(String value)
      wrap attribute.

      Specifies how the text in the textarea should be wrapped when the form is submitted.

      Possible values:

      • "soft" - Text is wrapped in the display but not in the submitted value (default)
      • "hard" - Text is wrapped in both display and submitted value
      • "off" - Text is not wrapped
      Parameters:
      value - How the text should be wrapped for form submission. Can be null to unset the attribute.
      Returns:
      This object.