Class Textarea


@Bean(typeName="textarea") public class Textarea extends HtmlElementRawText
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:
      autocomplete - Autocomplete behavior for the form field.
      Returns:
      This object.
    • autofocus

      public Textarea autofocus(Object value)
      autofocus attribute.

      Automatically focus the form control when the page is loaded.

      Parameters:
      autofocus - The new value for this attribute. Typically a Boolean or String.
      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:
      cols - The visible width of the textarea in characters.
      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:
      dirname - The name of the hidden field for directionality information.
      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:
      disabled - The new value for this attribute. Typically a Boolean or String.
      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:
      form - The ID of the form element to associate with this textarea.
      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:
      inputmode - The type of virtual keyboard to display.
      Returns:
      This object.
    • maxlength

      public Textarea maxlength(Object value)
      maxlength attribute.

      Maximum length of value.

      Parameters:
      maxlength - The new value for this attribute. Typically a Number or String.
      Returns:
      This object.
    • minlength

      public Textarea minlength(Object value)
      minlength attribute.

      Minimum length of value.

      Parameters:
      minlength - The new value for this attribute. Typically a Number or String.
      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:
      name - The name of the form control for submission and API access.
      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:
      placeholder - The placeholder text to display when the textarea is empty.
      Returns:
      This object.
    • readonly

      public Textarea readonly(Object value)
      readonly attribute.

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

      Parameters:
      readonly - The new value for this attribute. Typically a Boolean or String.
      Returns:
      This object.
    • required

      public Textarea required(Object value)
      required attribute.

      Whether the control is required for form submission.

      Parameters:
      required - The new value for this attribute. Typically a Boolean or String.
      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:
      rows - The visible height of the textarea in lines.
      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:
      wrap - How the text should be wrapped for form submission.
      Returns:
      This object.
    • _class

      public Textarea _class(String value)
      Description copied from class: HtmlElement
      class attribute.

      Specifies one or more CSS class names for the element, separated by spaces. These classes can be used for styling and JavaScript selection.

      Overrides:
      _class in class HtmlElementRawText
      Returns:
      This object.
    • accesskey

      public Textarea accesskey(String value)
      Description copied from class: HtmlElement
      accesskey attribute.

      Defines a keyboard shortcut to activate or focus an element. The value should be a single character that, when pressed with a modifier key (usually Alt), activates the element.

      Overrides:
      accesskey in class HtmlElementRawText
      Returns:
      This object.
    • contenteditable

      Description copied from class: HtmlElement
      contenteditable attribute.

      Indicates whether the element's content is editable by the user.

      Possible values:

      • "true" or empty string - Element content is editable
      • "false" - Element content is not editable
      • "plaintext-only" - Element content is editable, but rich text formatting is disabled
      Overrides:
      contenteditable in class HtmlElementRawText
      Returns:
      This object.
    • dir

      public Textarea dir(String value)
      Description copied from class: HtmlElement
      dir attribute.

      Specifies the text direction of the element's content.

      Possible values:

      • "ltr" - Left-to-right text direction
      • "rtl" - Right-to-left text direction
      • "auto" - Browser determines direction based on content
      Overrides:
      dir in class HtmlElementRawText
      Returns:
      This object.
    • hidden

      public Textarea hidden(Object value)
      Description copied from class: HtmlElement
      hidden attribute.

      This attribute uses deminimized values:

      • false - Attribute is not added
      • true - Attribute is added as "hidden"
      • Other values - Passed through as-is
      Overrides:
      hidden in class HtmlElementRawText
      Returns:
      This object.
    • id

      public Textarea id(String value)
      Description copied from class: HtmlElement
      id attribute.

      Specifies a unique identifier for the element. The ID must be unique within the document and can be used for CSS styling, JavaScript selection, and anchor links.

      Overrides:
      id in class HtmlElementRawText
      Returns:
      This object.
    • lang

      public Textarea lang(String value)
      Description copied from class: HtmlElement
      lang attribute.

      Specifies the primary language of the element's content using a language tag. This helps with accessibility, search engines, and browser features like spell checking.

      Overrides:
      lang in class HtmlElementRawText
      Returns:
      This object.
    • onabort

      public Textarea onabort(String value)
      Description copied from class: HtmlElement
      onabort attribute.

      Event handler for when an operation is aborted (e.g., image loading is cancelled).

      Overrides:
      onabort in class HtmlElementRawText
      Returns:
      This object.
    • onblur

      public Textarea onblur(String value)
      Description copied from class: HtmlElement
      onblur attribute.

      Event handler for when the element loses focus.

      Note:

      If your HTML serializer is configured to use single quotes for attribute values, you should use double quotes in your JavaScript code, and vice versa. Otherwise, the quotes will be converted to HTML entities. For example:

      • If using single quotes for attributes: onblur("validate(\"email\")")
      • If using double quotes for attributes: onblur("validate('email')")
      Overrides:
      onblur in class HtmlElementRawText
      Returns:
      This object.
    • oncancel

      public Textarea oncancel(String value)
      Description copied from class: HtmlElement
      oncancel attribute.

      Event handler for when a dialog is cancelled.

      Overrides:
      oncancel in class HtmlElementRawText
      Returns:
      This object.
    • oncanplay

      public Textarea oncanplay(String value)
      Description copied from class: HtmlElement
      oncanplay attribute.

      Event handler for when the media can start playing (enough data has been buffered).

      Overrides:
      oncanplay in class HtmlElementRawText
      Returns:
      This object.
    • oncanplaythrough

      Description copied from class: HtmlElement
      oncanplaythrough attribute.

      Event handler for when the media can play through to the end without buffering.

      Overrides:
      oncanplaythrough in class HtmlElementRawText
      Returns:
      This object.
    • onchange

      public Textarea onchange(String value)
      Description copied from class: HtmlElement
      onchange attribute.

      Event handler for when the value of a form element changes and loses focus.

      Note:

      If your HTML serializer is configured to use single quotes for attribute values, you should use double quotes in your JavaScript code, and vice versa. Otherwise, the quotes will be converted to HTML entities. For example:

      • If using single quotes for attributes: onchange("validate(\"field\")")
      • If using double quotes for attributes: onchange("validate('field')")
      Overrides:
      onchange in class HtmlElementRawText
      Returns:
      This object.
    • onclick

      public Textarea onclick(String value)
      Description copied from class: HtmlElement
      onclick attribute.

      Event handler for when the element is clicked.

      Note:

      If your HTML serializer is configured to use single quotes for attribute values, you should use double quotes in your JavaScript code, and vice versa. Otherwise, the quotes will be converted to HTML entities. For example:

      • If using single quotes for attributes: onclick("alert(\"Hello\")")
      • If using double quotes for attributes: onclick("alert('Hello')")
      Overrides:
      onclick in class HtmlElementRawText
      Returns:
      This object.
    • oncuechange

      public Textarea oncuechange(String value)
      Description copied from class: HtmlElement
      oncuechange attribute.

      Event handler for when a text track cue changes.

      Overrides:
      oncuechange in class HtmlElementRawText
      Returns:
      This object.
    • ondblclick

      public Textarea ondblclick(String value)
      Description copied from class: HtmlElement
      ondblclick attribute.

      Event handler for when the element is double-clicked.

      Overrides:
      ondblclick in class HtmlElementRawText
      Returns:
      This object.
    • ondurationchange

      Description copied from class: HtmlElement
      ondurationchange attribute.

      Event handler for when the duration of the media changes.

      Overrides:
      ondurationchange in class HtmlElementRawText
      Returns:
      This object.
    • onemptied

      public Textarea onemptied(String value)
      Description copied from class: HtmlElement
      onemptied attribute.

      Event handler for when the media element becomes empty (e.g., network error).

      Overrides:
      onemptied in class HtmlElementRawText
      Returns:
      This object.
    • onended

      public Textarea onended(String value)
      Description copied from class: HtmlElement
      onended attribute.

      Event handler for when the media playback reaches the end.

      Overrides:
      onended in class HtmlElementRawText
      Returns:
      This object.
    • onerror

      public Textarea onerror(String value)
      Description copied from class: HtmlElement
      onerror attribute.

      Event handler for when an error occurs (e.g., failed resource loading).

      Overrides:
      onerror in class HtmlElementRawText
      Returns:
      This object.
    • onfocus

      public Textarea onfocus(String value)
      Description copied from class: HtmlElement
      onfocus attribute.

      Event handler for when the element receives focus.

      Note:

      If your HTML serializer is configured to use single quotes for attribute values, you should use double quotes in your JavaScript code, and vice versa. Otherwise, the quotes will be converted to HTML entities. For example:

      • If using single quotes for attributes: onfocus("highlight(\"field\")")
      • If using double quotes for attributes: onfocus("highlight('field')")
      Overrides:
      onfocus in class HtmlElementRawText
      Returns:
      This object.
    • oninput

      public Textarea oninput(String value)
      Description copied from class: HtmlElement
      oninput attribute.

      Event handler for when the value of an input element changes (fires on every keystroke).

      Overrides:
      oninput in class HtmlElementRawText
      Returns:
      This object.
    • oninvalid

      public Textarea oninvalid(String value)
      Description copied from class: HtmlElement
      oninvalid attribute.

      Event handler for when form validation fails.

      Overrides:
      oninvalid in class HtmlElementRawText
      Returns:
      This object.
    • onkeydown

      public Textarea onkeydown(String value)
      Description copied from class: HtmlElement
      onkeydown attribute.

      Event handler for when a key is pressed down.

      Overrides:
      onkeydown in class HtmlElementRawText
      Returns:
      This object.
    • onkeypress

      public Textarea onkeypress(String value)
      Description copied from class: HtmlElement
      onkeypress attribute.

      Event handler for when a key is pressed (deprecated, use onkeydown instead).

      Overrides:
      onkeypress in class HtmlElementRawText
      Returns:
      This object.
    • onkeyup

      public Textarea onkeyup(String value)
      Description copied from class: HtmlElement
      onkeyup attribute.

      Event handler for when a key is released.

      Overrides:
      onkeyup in class HtmlElementRawText
      Returns:
      This object.
    • onload

      public Textarea onload(String value)
      Description copied from class: HtmlElement
      onload attribute.

      Event handler for when the element and its resources have finished loading.

      Note:

      If your HTML serializer is configured to use single quotes for attribute values, you should use double quotes in your JavaScript code, and vice versa. Otherwise, the quotes will be converted to HTML entities. For example:

      • If using single quotes for attributes: onload("init(\"config\")")
      • If using double quotes for attributes: onload("init('config')")
      Overrides:
      onload in class HtmlElementRawText
      Returns:
      This object.
    • onloadeddata

      public Textarea onloadeddata(String value)
      Description copied from class: HtmlElement
      onloadeddata attribute.

      Event handler for when the first frame of media has finished loading.

      Overrides:
      onloadeddata in class HtmlElementRawText
      Returns:
      This object.
    • onloadedmetadata

      Description copied from class: HtmlElement
      onloadedmetadata attribute.

      Event handler for when metadata (duration, dimensions, etc.) has been loaded.

      Overrides:
      onloadedmetadata in class HtmlElementRawText
      Returns:
      This object.
    • onloadstart

      public Textarea onloadstart(String value)
      Description copied from class: HtmlElement
      onloadstart attribute.

      Event handler for when the browser starts loading the media.

      Overrides:
      onloadstart in class HtmlElementRawText
      Returns:
      This object.
    • onmousedown

      public Textarea onmousedown(String value)
      Description copied from class: HtmlElement
      onmousedown attribute.

      Event handler for when a mouse button is pressed down on the element.

      Overrides:
      onmousedown in class HtmlElementRawText
      Returns:
      This object.
    • onmouseenter

      public Textarea onmouseenter(String value)
      Description copied from class: HtmlElement
      onmouseenter attribute.

      Event handler for when the mouse pointer enters the element (does not bubble).

      Overrides:
      onmouseenter in class HtmlElementRawText
      Returns:
      This object.
    • onmouseleave

      public Textarea onmouseleave(String value)
      Description copied from class: HtmlElement
      onmouseleave attribute.

      Event handler for when the mouse pointer leaves the element (does not bubble).

      Overrides:
      onmouseleave in class HtmlElementRawText
      Returns:
      This object.
    • onmousemove

      public Textarea onmousemove(String value)
      Description copied from class: HtmlElement
      onmousemove attribute.

      Event handler for when the mouse pointer moves over the element.

      Overrides:
      onmousemove in class HtmlElementRawText
      Returns:
      This object.
    • onmouseout

      public Textarea onmouseout(String value)
      Description copied from class: HtmlElement
      onmouseout attribute.

      Event handler for when the mouse pointer moves out of the element (bubbles).

      Overrides:
      onmouseout in class HtmlElementRawText
      Returns:
      This object.
    • onmouseover

      public Textarea onmouseover(String value)
      Description copied from class: HtmlElement
      onmouseover attribute.

      Event handler for when the mouse pointer moves over the element (bubbles).

      Note:

      If your HTML serializer is configured to use single quotes for attribute values, you should use double quotes in your JavaScript code, and vice versa. Otherwise, the quotes will be converted to HTML entities. For example:

      • If using single quotes for attributes: onmouseover("showTooltip(\"info\")")
      • If using double quotes for attributes: onmouseover("showTooltip('info')")
      Overrides:
      onmouseover in class HtmlElementRawText
      Returns:
      This object.
    • onmouseup

      public Textarea onmouseup(String value)
      Description copied from class: HtmlElement
      onmouseup attribute.

      Event handler for when a mouse button is released over the element.

      Overrides:
      onmouseup in class HtmlElementRawText
      Returns:
      This object.
    • onmousewheel

      public Textarea onmousewheel(String value)
      Description copied from class: HtmlElement
      onmousewheel attribute.

      Event handler for when the mouse wheel is rotated over the element (deprecated, use onwheel).

      Overrides:
      onmousewheel in class HtmlElementRawText
      Returns:
      This object.
    • onpause

      public Textarea onpause(String value)
      Description copied from class: HtmlElement
      onpause attribute.

      Event handler for when media playback is paused.

      Overrides:
      onpause in class HtmlElementRawText
      Returns:
      This object.
    • onplay

      public Textarea onplay(String value)
      Description copied from class: HtmlElement
      onplay attribute.

      Event handler for when media playback starts.

      Overrides:
      onplay in class HtmlElementRawText
      Returns:
      This object.
    • onplaying

      public Textarea onplaying(String value)
      Description copied from class: HtmlElement
      onplaying attribute.

      Event handler for when media playback starts after being paused or delayed.

      Overrides:
      onplaying in class HtmlElementRawText
      Returns:
      This object.
    • onprogress

      public Textarea onprogress(String value)
      Description copied from class: HtmlElement
      onprogress attribute.

      Event handler for when the browser is downloading media data.

      Overrides:
      onprogress in class HtmlElementRawText
      Returns:
      This object.
    • onratechange

      public Textarea onratechange(String value)
      Description copied from class: HtmlElement
      onratechange attribute.

      Event handler for when the playback rate of media changes.

      Overrides:
      onratechange in class HtmlElementRawText
      Returns:
      This object.
    • onreset

      public Textarea onreset(String value)
      Description copied from class: HtmlElement
      onreset attribute.

      Event handler for when a form is reset.

      Overrides:
      onreset in class HtmlElementRawText
      Returns:
      This object.
    • onresize

      public Textarea onresize(String value)
      Description copied from class: HtmlElement
      onresize attribute.

      Event handler for when the element is resized.

      Overrides:
      onresize in class HtmlElementRawText
      Returns:
      This object.
    • onscroll

      public Textarea onscroll(String value)
      Description copied from class: HtmlElement
      onscroll attribute.

      Event handler for when the element's scrollbar is scrolled.

      Overrides:
      onscroll in class HtmlElementRawText
      Returns:
      This object.
    • onseeked

      public Textarea onseeked(String value)
      Description copied from class: HtmlElement
      onseeked attribute.

      Event handler for when a seek operation completes.

      Overrides:
      onseeked in class HtmlElementRawText
      Returns:
      This object.
    • onseeking

      public Textarea onseeking(String value)
      Description copied from class: HtmlElement
      onseeking attribute.

      Event handler for when a seek operation begins.

      Overrides:
      onseeking in class HtmlElementRawText
      Returns:
      This object.
    • onselect

      public Textarea onselect(String value)
      Description copied from class: HtmlElement
      onselect attribute.

      Event handler for when text is selected in the element.

      Overrides:
      onselect in class HtmlElementRawText
      Returns:
      This object.
    • onshow

      public Textarea onshow(String value)
      Description copied from class: HtmlElement
      onshow attribute.

      Event handler for when a context menu is shown.

      Overrides:
      onshow in class HtmlElementRawText
      Returns:
      This object.
    • onstalled

      public Textarea onstalled(String value)
      Description copied from class: HtmlElement
      onstalled attribute.

      Event handler for when media loading is stalled.

      Overrides:
      onstalled in class HtmlElementRawText
      Returns:
      This object.
    • onsubmit

      public Textarea onsubmit(String value)
      Description copied from class: HtmlElement
      onsubmit attribute.

      Event handler for when a form is submitted.

      Note:

      If your HTML serializer is configured to use single quotes for attribute values, you should use double quotes in your JavaScript code, and vice versa. Otherwise, the quotes will be converted to HTML entities. For example:

      • If using single quotes for attributes: onsubmit("return validate(\"form\")")
      • If using double quotes for attributes: onsubmit("return validate('form')")
      Overrides:
      onsubmit in class HtmlElementRawText
      Returns:
      This object.
    • onsuspend

      public Textarea onsuspend(String value)
      Description copied from class: HtmlElement
      onsuspend attribute.

      Event handler for when media loading is suspended.

      Overrides:
      onsuspend in class HtmlElementRawText
      Returns:
      This object.
    • ontimeupdate

      public Textarea ontimeupdate(String value)
      Description copied from class: HtmlElement
      ontimeupdate attribute.

      Event handler for when the current playback position changes.

      Overrides:
      ontimeupdate in class HtmlElementRawText
      Returns:
      This object.
    • ontoggle

      public Textarea ontoggle(String value)
      Description copied from class: HtmlElement
      ontoggle attribute.

      Event handler for when a details element is opened or closed.

      Overrides:
      ontoggle in class HtmlElementRawText
      Returns:
      This object.
    • onvolumechange

      public Textarea onvolumechange(String value)
      Description copied from class: HtmlElement
      onvolumechange attribute.

      Event handler for when the volume of media changes.

      Overrides:
      onvolumechange in class HtmlElementRawText
      Returns:
      This object.
    • onwaiting

      public Textarea onwaiting(String value)
      Description copied from class: HtmlElement
      onwaiting attribute.

      Event handler for when media playback stops to buffer more data.

      Overrides:
      onwaiting in class HtmlElementRawText
      Returns:
      This object.
    • spellcheck

      public Textarea spellcheck(Object value)
      Description copied from class: HtmlElement
      spellcheck attribute.

      Indicates whether the element should have its spelling and grammar checked.

      Possible values:

      • "true" - Enable spell checking for this element
      • "false" - Disable spell checking for this element
      Overrides:
      spellcheck in class HtmlElementRawText
      Returns:
      This object.
    • style

      public Textarea style(String value)
      Description copied from class: HtmlElement
      style attribute.

      Specifies inline CSS styles for the element. The value should be valid CSS property-value pairs separated by semicolons.

      Overrides:
      style in class HtmlElementRawText
      Returns:
      This object.
    • tabindex

      public Textarea tabindex(Object value)
      Description copied from class: HtmlElement
      tabindex attribute.

      Specifies the tab order of the element when navigating with the keyboard.

      Possible values:

      • Positive integer - Element is focusable and participates in tab order
      • "0" - Element is focusable but not in tab order
      • Negative integer - Element is not focusable
      Overrides:
      tabindex in class HtmlElementRawText
      Returns:
      This object.
    • title

      public Textarea title(String value)
      Description copied from class: HtmlElement
      title attribute.

      Specifies additional information about the element, typically displayed as a tooltip when the user hovers over the element.

      Overrides:
      title in class HtmlElementRawText
      Returns:
      This object.
    • translate

      public Textarea translate(Object value)
      Description copied from class: HtmlElement
      translate attribute.

      Specifies whether the element's content should be translated when the page is localized.

      Possible values:

      • "yes" - Content should be translated (default)
      • "no" - Content should not be translated
      Overrides:
      translate in class HtmlElementRawText
      Returns:
      This object.
    • text

      public Textarea text(Object value)
      Description copied from class: HtmlElementRawText
      Sets the text node on this element.
      Overrides:
      text in class HtmlElementRawText
      Returns:
      This object.