Class Textarea
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:
The following convenience methods are provided for constructing instances of this bean:
See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionTextarea()Creates an emptyTextareaelement.Creates aTextareaelement with the specifiedname(String)attribute andHtmlElementRawText.text(Object)node. -
Method Summary
Modifier and TypeMethodDescriptionautocomplete(String value) autocomplete attribute.autofocus attribute.cols attribute.dirname attribute.disabled attribute.form attribute.inputmode attribute.maxlength attribute.minlength attribute.name attribute.placeholder(String value) placeholder attribute.readonly attribute.required attribute.rows attribute.wrap attribute.Methods inherited from class org.apache.juneau.bean.html5.HtmlElementRawText
getText, setText, textMethods inherited from class org.apache.juneau.bean.html5.HtmlElement
accesskey, attr, attrUri, class_, contenteditable, deminimize, dir, getAttr, getAttr, getAttrs, hidden, id, lang, onabort, onblur, oncancel, oncanplay, oncanplaythrough, onchange, onclick, oncuechange, ondblclick, ondurationchange, onemptied, onended, onerror, onfocus, oninput, oninvalid, onkeydown, onkeypress, onkeyup, onload, onloadeddata, onloadedmetadata, onloadstart, onmousedown, onmouseenter, onmouseleave, onmousemove, onmouseout, onmouseover, onmouseup, onmousewheel, onpause, onplay, onplaying, onprogress, onratechange, onreset, onresize, onscroll, onseeked, onseeking, onselect, onshow, onstalled, onsubmit, onsuspend, ontimeupdate, ontoggle, onvolumechange, onwaiting, self, setAttrs, spellcheck, style, tabindex, title, toString, translate
-
Constructor Details
-
Textarea
public Textarea()Creates an emptyTextareaelement. -
Textarea
Creates aTextareaelement with the specifiedname(String)attribute andHtmlElementRawText.text(Object)node.- Parameters:
name- Thename(String)attribute. Can benull to unset the attribute.text- TheHtmlElementRawText.text(Object)node. Can benull to leave the text unset.
-
-
Method Details
-
autocomplete
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 benull to unset the attribute.- Returns:
- This object.
-
autofocus
autofocus attribute.Automatically focus the form control when the page is loaded.
-
cols
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 benull to unset the attribute.- Returns:
- This object.
-
dirname
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 benull to unset the attribute.- Returns:
- This object.
-
disabled
disabled attribute.Whether the form control is disabled.
This attribute uses deminimized values:
false - Attribute is not addedtrue - Attribute is added as"disabled" - Other values - Passed through as-is
-
form
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 benull to unset the attribute.- Returns:
- This object.
-
inputmode
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 benull to unset the attribute.- Returns:
- This object.
-
maxlength
maxlength attribute.Maximum length of value.
-
minlength
minlength attribute.Minimum length of value.
-
name
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 benull to unset the attribute.- Returns:
- This object.
-
placeholder
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 benull to unset the attribute.- Returns:
- This object.
-
readonly
readonly attribute.Whether to allow the value to be edited by the user.
-
required
required attribute.Whether the control is required for form submission.
-
rows
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 benull to unset the attribute.- Returns:
- This object.
-
wrap
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 benull to unset the attribute.- Returns:
- This object.
-