Class InputElement<T extends InputElement<T>>
This abstract base class extends StyledElement to provide common functionality for all input-like elements. It manages the input's name, value, and state, handles value change events, and provides HTML5 input attributes. This class serves as the foundation for the Input class and related input controls.
Features:
- Name and value attribute management
- Value change tracking and event dispatching
- Initial value preservation for reset functionality
- HTML5 input attributes (autocomplete, autofocus, placeholder, etc.)
- Validation attributes (required, pattern, min, max, etc.)
- Focus management with command support
- Form association and validation control
Usage:
// Typically extended by Input class
public class CustomInput extends InputElement {
public CustomInput() {
super("input", true);
}
}
- Since:
- 2007
- Version:
- 1.0
- Author:
- Marvin P. Warble Jr.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionInputElement(String tagName) Creates an InputElement with the specified tag name as a self-closing element.InputElement(String tagName, boolean closed) Creates an InputElement with the specified tag name and closing behavior. -
Method Summary
Modifier and TypeMethodDescriptionfinal InputElementassociateLabel(Label label) Associates this input with a label element.final voidfocus()Requests focus on this input element.protected StringReturns the autocomplete attribute value.protected StringReturns the dirname attribute value.protected StringReturns the formaction attribute value.protected StringReturns the formenctype attribute value.protected StringReturns the formmethod attribute value.protected StringReturns the formtarget attribute value.protected StringgetMax()Returns the max attribute value.protected intReturns the maxlength attribute value.protected StringgetMin()Returns the min attribute value.protected intReturns the minlength attribute value.final StringgetName()Returns the name attribute value.protected StringReturns the placeholder attribute value.protected intgetSize()Returns the size attribute value.getValue()Returns the current value of the input.protected booleanReturns whether the formnovalidate attribute is set.protected booleanReturns whether the multiple attribute is set.protected booleanReturns whether the readonly attribute is set.protected booleanReturns whether the required attribute is set.protected voidCalled when the input value changes.voidonValueInitialized(String value, String state) Called when the value is first initialized from the client.voidonValueUpdate(String value, String state) Called when the value is updated from the client.booleanreset()Resets the input value to its initial value.Sets the accept attribute specifying accepted content types for file inputs.final TsetAutocomplete(boolean on) Sets the autocomplete attribute to enable or disable browser autocomplete.setCapture(String capture) Sets the capture attribute for media capture on mobile devices.setChecked(boolean checked) Sets the checked boolean attribute.final InputElementsetDescription(Element descriptionElement) Associates this input with an element providing additional description.final TsetDirName(String dirname) Sets the dirname attribute for text directionality submission.final TsetDisabled(boolean disabled) Sets the disabled boolean attribute.final InputElementsetErrorDisplay(Element errorElement) Sets up an accessible error display for this input.final TAssociates this input with a form element.protected TsetFormAction(String formAction) Sets the formaction attribute.protected TsetFormEncType(FormEncoding formEncType) Sets the form encoding type override using theFormEncodingenum.protected TsetFormEncType(String formEncType) Sets the formenctype attribute.protected TsetFormMethod(FormMethod formMethod) Sets the form method override using theFormMethodenum.protected TsetFormMethod(String formMethod) Sets the formmethod attribute.final TsetFormNoValidate(boolean flag) Sets the formnovalidate boolean attribute.protected TsetFormTarget(Target formTarget) Sets the form target override using theTargetenum.protected TsetFormTarget(String formTarget) Sets the formtarget attribute.final InputElementsetHasError(boolean hasError) Marks this input as having or not having an error.final TSets the list attribute linking this input to a<datalist>element.final TSets the max attribute specifying the maximum allowed value.final TsetMaxLength(int value) Sets the maxlength attribute specifying the maximum number of characters allowed.final TsetMaxLength(String value) Sets the maximum character length allowed, parsing the string value as an integer.final TSets the min attribute specifying the minimum allowed value.final TsetMinLength(int value) Sets the minlength attribute specifying the minimum number of characters required.final TsetMultiple(boolean flag) Sets the multiple boolean attribute to allow selection of multiple values.final TSets the name attribute for this input element.final TsetPattern(String regexp) Sets the regular expression pattern for input validation.final TsetPlaceholder(String placeholder) Sets the placeholder attribute providing a short hint for expected input.final TsetReadOnly(boolean flag) Sets the readonly boolean attribute preventing user modification.final TsetRequired(boolean flag) Sets the required boolean attribute indicating the field must be filled before form submission.final InputElementsetRequiredAccessible(boolean required) Sets this input as required with proper accessibility attributes.final TsetSize(int numChars) Sets the size attribute specifying the visible width in characters.final TSets the step interval for numeric and date/time inputs.final TSets the current value of the input element.Methods inherited from class com.oorian.html.StyledElement
addClass, addStyle, addStyle, addStyleAttribute, addTransition, animate, clearTransitions, getActiveStyle, getCssClass, getDisabledStyle, getFocusStyle, getFocusVisibleStyle, getHoverStyle, getHtml, getStyle, getStyleAttribute, hidden, hide, initialize, isDisplayed, isTransitionForwardActive, onHide, onRemovedFromPage, onShow, removeClass, setActiveStyle, setAlignContent, setAlignContent, setAlignItems, setAlignItems, setAlignSelf, setAlignSelf, setAnimation, setAnimationDelay, setAnimationDelay, setAnimationDelay, setAnimationDirection, setAnimationDirection, setAnimationDuration, setAnimationDuration, setAnimationDuration, setAnimationFillMode, setAnimationFillMode, setAnimationIterationCount, setAnimationIterationCount, setAnimationIterationCount, setAnimationName, setAnimationPlayState, setAnimationPlayState, setAnimationTimingFunction, setAnimationTimingFunction, setAnimationTimingFunction, setAnimationTimingFunction, setBackdropFilter, setBackdropFilter, setBackfaceVisibility, setBackfaceVisibility, setBackground, setBackground, setBackgroundAttachment, setBackgroundAttachment, setBackgroundBlendMode, setBackgroundBlendMode, setBackgroundClip, setBackgroundClip, setBackgroundColor, setBackgroundColor, setBackgroundColor, setBackgroundImage, setBackgroundImage, setBackgroundOrigin, setBackgroundOrigin, setBackgroundPosition, setBackgroundPosition, setBackgroundPosition, setBackgroundPosition, setBackgroundPosition, setBackgroundRepeat, setBackgroundRepeat, setBackgroundSize, setBackgroundSize, setBackgroundSize, setBackgroundSize, setBackgroundSize, setBlur, setBorder, setBorder, setBorder, setBorder, setBorder, setBorder, setBorder, setBorder, setBorder, setBorderBottom, setBorderBottom, setBorderBottom, setBorderBottom, setBorderBottom, setBorderBottom, setBorderBottom, setBorderBottom, setBorderBottomColor, setBorderBottomColor, setBorderBottomLeftRadius, setBorderBottomLeftRadius, setBorderBottomLeftRadius, setBorderBottomRightRadius, setBorderBottomRightRadius, setBorderBottomRightRadius, setBorderBottomStyle, setBorderBottomStyle, setBorderBottomWidth, setBorderBottomWidth, setBorderBottomWidth, setBorderBottomWidth, setBorderColor, setBorderColor, setBorderColor, setBorderColor, setBorderImage, setBorderImage, setBorderImageOutset, setBorderImageRepeat, setBorderImageSlice, setBorderImageSource, setBorderImageWidth, setBorderLeft, setBorderLeft, setBorderLeft, setBorderLeft, setBorderLeft, setBorderLeft, setBorderLeft, setBorderLeft, setBorderLeftColor, setBorderLeftColor, setBorderLeftStyle, setBorderLeftStyle, setBorderLeftWidth, setBorderLeftWidth, setBorderLeftWidth, setBorderLeftWidth, setBorderRadius, setBorderRadius, setBorderRadius, setBorderRadius, setBorderRadius, setBorderRadius, setBorderRight, setBorderRight, setBorderRight, setBorderRight, setBorderRight, setBorderRight, setBorderRight, setBorderRight, setBorderRightColor, setBorderRightColor, setBorderRightStyle, setBorderRightStyle, setBorderRightWidth, setBorderRightWidth, setBorderRightWidth, setBorderRightWidth, setBorderStyle, setBorderStyle, setBorderTop, setBorderTop, setBorderTop, setBorderTop, setBorderTop, setBorderTop, setBorderTop, setBorderTop, setBorderTopColor, setBorderTopColor, setBorderTopLeftRadius, setBorderTopLeftRadius, setBorderTopLeftRadius, setBorderTopRightRadius, setBorderTopRightRadius, setBorderTopRightRadius, setBorderTopStyle, setBorderTopStyle, setBorderTopWidth, setBorderTopWidth, setBorderTopWidth, setBorderTopWidth, setBorderWidth, setBorderWidth, setBorderWidth, setBorderWidth, setBorderWidth, setBorderWidth, setBorderWidth, setBottom, setBottom, setBottom, setBoxShadow, setBoxShadow, setBoxShadow, setBoxShadow, setBoxShadow, setBoxSizing, setBoxSizing, setBreakAfter, setBreakBefore, setBreakInside, setBrightness, setClass, setClear, setClear, setClip, setClipPath, setClipPath, setColGap, setColGap, setColor, setColor, setColumnCount, setColumnCount, setColumnFill, setColumnFill, setColumnGap, setColumnRule, setColumnRuleColor, setColumnRuleColor, setColumnRuleStyle, setColumnRuleStyle, setColumnRuleWidth, setColumnRuleWidth, setColumns, setColumns, setColumns, setColumnSpan, setColumnWidth, setColumnWidth, setColumnWidth, setContrast, setCounterIncrement, setCounterReset, setCursor, setCursor, setDirection, setDirection, setDisabledStyle, setDisplay, setDisplay, setFilter, setFilter, setFilterOpacity, setFlex, setFlexBasis, setFlexDirection, setFlexDirection, setFlexFlow, setFlexGrow, setFlexGrow, setFlexShrink, setFlexShrink, setFlexWrap, setFlexWrap, setFloat, setFloat, setFocusStyle, setFocusVisibleStyle, setFont, setFont, setFont, setFont, setFont, setFont, setFont, setFont, setFont, setFont, setFont, setFont, setFontFace, setFontFamily, setFontFamily, setFontFeatureSettings, setFontKerning, setFontLanguageOverride, setFontSize, setFontSize, setFontSize, setFontSizeAdjust, setFontStretch, setFontStretch, setFontStyle, setFontStyle, setFontSynthesis, setFontVariant, setFontVariant, setFontVariantAlternates, setFontVariantCaps, setFontVariantEastAsian, setFontVariantLigatures, setFontVariantNumeric, setFontVariantPosition, setFontWeight, setFontWeight, setGap, setGap, setGap, setGap, setGrayscale, setHangingPunctuation, setHangingPunctuation, setHeight, setHeight, setHeight, setHoverStyle, setHueRotate, setHyphens, setImageOrientation, setImageRendering, setImageResolution, setImeMode, setInvert, setJustifyContent, setJustifyContent, setKeyFrames, setLeft, setLeft, setLeft, setLetterSpacing, setLetterSpacing, setLetterSpacing, setLetterSpacing, setLineBreak, setLineHeight, setLineHeight, setLineHeight, setLineHeight, setMargin, setMargin, setMargin, setMargin, setMargin, setMarginBottom, setMarginBottom, setMarginBottom, setMarginLeft, setMarginLeft, setMarginLeft, setMarginRight, setMarginRight, setMarginRight, setMarginTop, setMarginTop, setMarginTop, setMark, setMarkAfter, setMarkBefore, setMarks, setMarqueeDirection, setMarqueePlayCount, setMarqueeSpeed, setMarqueeStyle, setMask, setMaskType, setMaxHeight, setMaxHeight, setMaxHeight, setMaxHeightToWindowHeight, setMaxWidth, setMaxWidth, setMaxWidth, setMaxWidthToWindowWidth, setMinHeight, setMinHeight, setMinHeight, setMinHeightToWindowHeight, setMinWidth, setMinWidth, setMinWidth, setMinWidthToWindowWidth, setNavDown, setNavIndex, setNavIndex, setNavLeft, setNavRight, setNavUp, setObjectFit, setObjectPosition, setOnClickNavigateBack, setOnClickNavigateBack, setOnClickNavigateBack, setOnClickNavigateForward, setOnClickNavigateForward, setOnClickNavigateForward, setOnClickNavigateTo, setOnDblClick, setOnDblClickChange, setOpacity, setOpacity, setOrder, setOrder, setOrphans, setOutline, setOutline, setOutline, setOutline, setOutlineColor, setOutlineColor, setOutlineOffset, setOutlineOffset, setOutlineOffset, setOutlineStyle, setOutlineStyle, setOutlineWidth, setOutlineWidth, setOutlineWidth, setOutlineWidth, setOverflow, setOverflow, setOverflow, setOverflowWrap, setOverflowX, setOverflowX, setOverflowY, setOverflowY, setPadding, setPadding, setPadding, setPadding, setPadding, setPadding, setPadding, setPadding, setPaddingBottom, setPaddingBottom, setPaddingBottom, setPaddingLeft, setPaddingLeft, setPaddingLeft, setPaddingRight, setPaddingRight, setPaddingRight, setPaddingTop, setPaddingTop, setPaddingTop, setPageBreakAfter, setPageBreakAfter, setPageBreakBefore, setPageBreakBefore, setPageBreakInside, setPageBreakInside, setPerspective, setPerspective, setPerspective, setPerspectiveOrigin, setPerspectiveOrigin, setPerspectiveOrigin, setPerspectiveOrigin, setPhonemes, setPosition, setPosition, setPosition, setPosition, setPosition, setQuotes, setResize, setResize, setResizeToWindowHeight, setResizeToWindowHeight, setResizeToWindowWidth, setRest, setRestAfter, setRestBefore, setRight, setRight, setRight, setRotate, setRotate, setRowGap, setRowGap, setSaturate, setScale, setScale, setSepia, setShow, setSize, setSize, setSize, setSkewX, setSkewY, setStyle, setStyle, setTabSize, setTabSize, setTabSize, setTabSize, setTextAlign, setTextAlign, setTextAlignLast, setTextAlignLast, setTextCombineUpright, setTextCombineWeight, setTextDecoration, setTextDecoration, setTextDecorationColor, setTextDecorationColor, setTextDecorationLine, setTextDecorationLine, setTextDecorationStyle, setTextDecorationStyle, setTextIndent, setTextIndent, setTextIndent, setTextIndent, setTextJustify, setTextJustify, setTextOrientation, setTextOverflow, setTextOverflow, setTextSelectDisabled, setTextShadow, setTextShadow, setTextShadow, setTextShadow, setTextShadow, setTextTransform, setTextTransform, setTextUnderlinePosition, setTop, setTop, setTop, setTransform, setTransform, setTransformOrigin, setTransformOrigin, setTransformOrigin, setTransformOrigin, setTransformOrigin, setTransformStyle, setTransformStyle, setTransition, setTransitionDelay, setTransitionDelay, setTransitionDelay, setTransitionDuration, setTransitionDuration, setTransitionDuration, setTransitionProperty, setTransitionTimingFunction, setTransitionTimingFunction, setTransitionTimingFunction, setTransitionTimingFunction, setTranslateX, setTranslateY, setTranslateZ, setUnicodeBidi, setUnicodeBidi, setVerticalAlign, setVerticalAlign, setVisibility, setVisibility, setVoiceBalance, setVoiceDuration, setVoicePitch, setVoicePitchRange, setVoiceRate, setVoiceStress, setVoiceVolume, setWhiteSpace, setWhiteSpace, setWidows, setWidth, setWidth, setWidth, setWordBreak, setWordBreak, setWordSpacing, setWordSpacing, setWordSpacing, setWordSpacing, setWordWrap, setWordWrap, setWritingMode, setZIndex, setZIndex, show, shown, stopAnimation, transitionForward, transitionForward, transitionReverse, transitionReverse, updateStyle, updateStyle, updateStyleIfChangedMethods inherited from class com.oorian.html.VisualElement
clearOnClick, click, disable, enable, getAccessKey, getAutoCapitalize, getEnterKeyHint, getInputMode, getPopover, getRole, getTabIndex, getTitle, isAutoFocus, isContentEditable, isDisabled, isDraggable, isHidden, isInert, isSpellCheck, onDisabled, onEnabled, setAccessKey, setAriaAtomic, setAriaBusy, setAriaChecked, setAriaCheckedMixed, setAriaControls, setAriaCurrent, setAriaDescribedBy, setAriaDisabled, setAriaErrorMessage, setAriaExpanded, setAriaHasPopup, setAriaHasPopup, setAriaHidden, setAriaInvalid, setAriaLabel, setAriaLabelledBy, setAriaLevel, setAriaLive, setAriaModal, setAriaOwns, setAriaPressed, setAriaRequired, setAriaSelected, setAriaValueRange, setAriaValueText, setAutoCapitalize, setAutoFocus, setConsumeEvent, setContentEditable, setDraggable, setDropAllowed, setEnterKeyHint, setFocus, setHidden, setInert, setInputMode, setOnAnimationCancel, setOnAnimationEnd, setOnAnimationIteration, setOnAnimationStart, setOnAuxClick, setOnBeforeInput, setOnBeforeToggle, setOnBlur, setOnChange, setOnClick, setOnClickChange, setOnCompositionEnd, setOnCompositionStart, setOnCompositionUpdate, setOnContextMenu, setOnCopy, setOnCut, setOnDocumentResize, setOnFocus, setOnFocusIn, setOnFocusOut, setOnFormData, setOnGotPointerCapture, setOnInput, setOnInvalid, setOnKeyDown, setOnKeyPressed, setOnKeyUp, setOnLostPointerCapture, setOnMouseDown, setOnMouseEnter, setOnMouseLeave, setOnMouseMove, setOnMouseOut, setOnMouseOutChangeClass, setOnMouseOutChangeStyle, setOnMouseOutChangeStyle, setOnMouseOver, setOnMouseOverChangeClass, setOnMouseOverChangeStyle, setOnMouseOverChangeStyle, setOnMouseOverShow, setOnMouseUp, setOnPageLoad, setOnPaste, setOnPointerCancel, setOnPointerDown, setOnPointerEnter, setOnPointerLeave, setOnPointerMove, setOnPointerOut, setOnPointerOver, setOnPointerUp, setOnResize, setOnScroll, setOnScrollEnd, setOnSelect, setOnSelectionChange, setOnSelectStart, setOnToggle, setOnTouchCancel, setOnTouchEnd, setOnTouchMove, setOnTouchStart, setOnTransitionCancel, setOnTransitionEnd, setOnTransitionRun, setOnTransitionStart, setOnWheel, setOnWindowResize, setPopover, setRole, setRole, setSpellCheck, setTabIndex, setTitle, setTooltipMethods inherited from class com.oorian.html.Element
addAttribute, addAttribute, addAttribute, addAttribute, addElement, addLineBreak, addLineOfText, addLineOfText, addLineOfText, addParagraph, addParagraph, addSpacer, addText, addText, addText, addText, assignId, containsElement, containsElement, create, dispatchEvent, dispatchEvent, dispatchEvent, dispatchEvent, equals, excludeId, executeJs, executeJs, executeJs, getAccept, getAllElements, getAncestor, getAttribute, getAttributes, getComponent, getDir, getElement, getElementById, getElementCount, getElementCount, getElements, getElements, getElementsByComponentName, getElementsByTagName, getHtml, getId, getInnerHtml, getInnerHtml, getIs, getItemId, getItemProp, getItemRef, getItemType, getLang, getNextSibling, getPage, getParent, getPart, getPrevSibling, getSlot, getTagName, getTextContent, getUrl, hasAttribute, hasElements, insertElement, isChildOf, isClosedTag, isCreated, isDescendantOf, isDescendantOf, isInitialized, isItemScope, isTranslate, onCallback, onCreated, onElementAdded, onElementRemoved, onHashChange, onHidden, onInitialized, onJsReturn, onPageLoaded, onPageUnloaded, onRefresh, onShown, onUpdated, onUserEvent, prewrite, recreate, refresh, refresh, registerAddition, registerListener, registerListener, registerListener, registerListener, registerListener, registerListener, registerListener, registerSubtraction, registerUpdate, removeAllElements, removeAttribute, removeAttribute, removeElement, removeElement, removeFromParent, requestCallback, requestCallback, requestCallback, requestCallback, resetId, scrollTo, scrollToBottom, scrollToTop, self, sendCommand, sendUpdate, setComponent, setDir, setDir, setElement, setId, setIs, setItemId, setItemProp, setItemRef, setItemScope, setItemType, setLang, setOnError, setOnLoad, setPage, setParent, setPart, setSlot, setTagName, setText, setText, setText, setText, setTranslate, toString, unregisterListener, update, updateAttributes
-
Constructor Details
-
InputElement
Creates an InputElement with the specified tag name as a self-closing element.- Parameters:
tagName- the HTML tag name (e.g., "input")
-
InputElement
Creates an InputElement with the specified tag name and closing behavior.- Parameters:
tagName- the HTML tag nameclosed- true for self-closing elements, false for elements with closing tags
-
-
Method Details
-
setName
Sets the name attribute for this input element.Specifies the name used as a key when submitting form data. The name identifies the input's value in the submitted form data.
- Parameters:
name- The name of the input element.- Returns:
- This element for method chaining.
-
setValue
Sets the current value of the input element.- Parameters:
value- the value to set, or null to clear
-
setAccept
Sets the accept attribute specifying accepted content types for file inputs.Used on
<input>elements withtype="file"to filter file selection. Accepts comma-separated MIME types or file extensions (e.g.,"image/*",".pdf,.doc").- Overrides:
setAcceptin classElement<T extends InputElement<T>>- Parameters:
accept- Comma-separated list of accepted content types.- Returns:
- This element for method chaining.
-
setCapture
Sets the capture attribute for media capture on mobile devices.Used on
<input>elements withtype="file". Values include"user"(front-facing camera) and"environment"(rear-facing camera).- Parameters:
capture- The capture value (user, environment).- Returns:
- This element for method chaining.
-
setChecked
Sets the checked boolean attribute.Indicates that the input should be pre-selected when the page loads. Used on
<input>elements withtype="checkbox"ortype="radio".- Parameters:
checked- True to check, false to uncheck.- Returns:
- This element for method chaining.
-
setAutocomplete
Sets the autocomplete attribute to enable or disable browser autocomplete.- Parameters:
on- true to enable autocomplete, false to disable- Returns:
- this element for method chaining
-
setDirName
Sets the dirname attribute for text directionality submission.Enables submission of the text directionality of the input field along with the form data. The value specifies the name under which the directionality will be submitted.
- Parameters:
dirname- the name for text directionality submission- Returns:
- this element for method chaining
-
setDisabled
Sets the disabled boolean attribute.Indicates that the element should be disabled, preventing user interaction and form submission. Used on
<button>,<fieldset>,<input>,<select>, and<textarea>elements. Disabled elements are typically rendered in a grayed-out style.- Overrides:
setDisabledin classVisualElement<T extends InputElement<T>>- Parameters:
disabled- True to disable, false to enable.- Returns:
- This element for method chaining.
-
setForm
Associates this input with a form element.Specifies the form this input belongs to using the form's ID. This is useful when the input is placed outside of its associated
<form>in the document.- Parameters:
formId- the ID of the form element to associate with- Returns:
- This element for method chaining.
-
setFormNoValidate
Sets the formnovalidate boolean attribute.Overrides the form's validation behavior for this specific submit button, bypassing constraint validation. Used on
<input>elements withtype="submit"ortype="image".- Parameters:
flag- True to skip form validation, false to remove.- Returns:
- This element for method chaining.
-
setFormAction
Sets the formaction attribute.Overrides the form's
actionattribute for this specific submit button. Used on<input>elements withtype="submit"ortype="image". The value specifies the URL to submit the form data to.If the URL starts with "/" (absolute path within the application), the servlet context path will be automatically prepended.
- Parameters:
formAction- The URL for form submission.- Returns:
- This element for method chaining.
-
setFormEncType
Sets the formenctype attribute.Overrides the form's
enctypeattribute for this specific submit button. Used on<input>elements withtype="submit"ortype="image".- Parameters:
formEncType- The encoding type for form submission.- Returns:
- This element for method chaining.
-
setFormEncType
Sets the form encoding type override using theFormEncodingenum.- Parameters:
formEncType- The encoding type.- Returns:
- This element for method chaining.
-
setFormMethod
Sets the formmethod attribute.Overrides the form's
methodattribute for this specific submit button. Used on<input>elements withtype="submit"ortype="image".- Parameters:
formMethod- The HTTP method for form submission (get, post).- Returns:
- This element for method chaining.
-
setFormMethod
Sets the form method override using theFormMethodenum.- Parameters:
formMethod- The HTTP method (GET or POST).- Returns:
- This element for method chaining.
-
setFormTarget
Sets the formtarget attribute.Overrides the form's
targetattribute for this specific submit button, specifying where to display the response. Used on<input>elements withtype="submit"ortype="image". Values include"_self","_blank","_parent", and"_top".- Parameters:
formTarget- The browsing context for form submission.- Returns:
- This element for method chaining.
-
setFormTarget
Sets the form target override using theTargetenum.- Parameters:
formTarget- The browsing context for form submission.- Returns:
- This element for method chaining.
-
setList
Sets the list attribute linking this input to a<datalist>element.The value must be the ID of a
DataListelement in the same document. The browser provides autocomplete suggestions from the datalist options.- Parameters:
list- the ID of the datalist element to link to- Returns:
- this element for method chaining
-
setMax
Sets the max attribute specifying the maximum allowed value.Used on input types like
number,range, anddate.- Parameters:
value- the maximum value- Returns:
- this element for method chaining
-
setMaxLength
Sets the maximum character length allowed, parsing the string value as an integer.- Parameters:
value- the maximum number of characters as a string- Returns:
- this element for method chaining
-
setMaxLength
Sets the maxlength attribute specifying the maximum number of characters allowed.- Parameters:
value- the maximum number of characters- Returns:
- this element for method chaining
-
setMin
Sets the min attribute specifying the minimum allowed value.Used on input types like
number,range, anddate.- Parameters:
value- the minimum value- Returns:
- this element for method chaining
-
setMinLength
Sets the minlength attribute specifying the minimum number of characters required.- Parameters:
value- the minimum number of characters- Returns:
- this element for method chaining
-
setMultiple
Sets the multiple boolean attribute to allow selection of multiple values.- Parameters:
flag- true to allow multiple values, false to remove- Returns:
- this element for method chaining
-
setPattern
Sets the regular expression pattern for input validation.The input's value must match this pattern for the form to be submitted. The pattern is matched against the entire value, not just a subset.
- Parameters:
regexp- the regular expression pattern to validate against- Returns:
- this element for method chaining
-
setPlaceholder
Sets the placeholder attribute providing a short hint for expected input.The placeholder text disappears when the user begins typing. Should not be used as a substitute for a
<label>element.- Parameters:
placeholder- the placeholder text- Returns:
- this element for method chaining
-
setReadOnly
Sets the readonly boolean attribute preventing user modification.Unlike
disabled, read-only fields remain focusable and their values are included in form submission.- Parameters:
flag- true to make read-only, false to remove- Returns:
- this element for method chaining
-
setRequired
Sets the required boolean attribute indicating the field must be filled before form submission.- Parameters:
flag- true to require input, false to remove- Returns:
- this element for method chaining
-
setSize
Sets the size attribute specifying the visible width in characters.- Parameters:
numChars- the number of visible characters- Returns:
- this element for method chaining
-
setStep
Sets the step interval for numeric and date/time inputs.Defines the legal number intervals for the input value. For example,
"2"means only even numbers are valid. Use"any"to allow any value.- Parameters:
number- the step interval (e.g., "1", "0.01", "any")- Returns:
- this element for method chaining
-
focus
public final void focus()Requests focus on this input element. -
getAutoComplete
Returns the autocomplete attribute value.- Returns:
- the autocomplete value, or
nullif not set
-
getDirName
Returns the dirname attribute value.- Returns:
- the dirname value, or
nullif not set
-
getMax
Returns the max attribute value.- Returns:
- the maximum value, or
nullif not set
-
getMaxLength
protected int getMaxLength()Returns the maxlength attribute value.- Returns:
- the maximum length, or -1 if not set
-
getMin
Returns the min attribute value.- Returns:
- the minimum value, or
nullif not set
-
getMinLength
protected int getMinLength()Returns the minlength attribute value.- Returns:
- the minimum length, or -1 if not set
-
isMultiple
protected boolean isMultiple()Returns whether the multiple attribute is set.- Returns:
trueif multiple is present,falseotherwise
-
getPlaceholder
Returns the placeholder attribute value.- Returns:
- the placeholder text, or
nullif not set
-
isReadOnly
protected boolean isReadOnly()Returns whether the readonly attribute is set.- Returns:
trueif readonly is present,falseotherwise
-
isRequired
protected boolean isRequired()Returns whether the required attribute is set.- Returns:
trueif required is present,falseotherwise
-
getSize
protected int getSize()Returns the size attribute value.- Returns:
- the size, or -1 if not set
-
getFormAction
Returns the formaction attribute value.The formaction attribute overrides the
actionattribute of the parent form for this specific submit button. Used on<input type="submit">and<input type="image">elements.- Returns:
- The form action URL, or
nullif not set.
-
getFormEncType
Returns the formenctype attribute value.The formenctype attribute overrides the
enctypeattribute of the parent form for this specific submit button. Used on<input type="submit">and<input type="image">elements.- Returns:
- The form encoding type, or
nullif not set.
-
getFormMethod
Returns the formmethod attribute value.The formmethod attribute overrides the
methodattribute of the parent form for this specific submit button. Used on<input type="submit">and<input type="image">elements. Values are"get","post", or"dialog".- Returns:
- The form method, or
nullif not set.
-
isFormNoValidate
protected boolean isFormNoValidate()Returns whether the formnovalidate attribute is set.The formnovalidate attribute overrides the
novalidateattribute of the parent form, bypassing constraint validation for this specific submit button. Used on<input type="submit">and<input type="image">elements.- Returns:
trueif formnovalidate is present,falseotherwise.
-
getFormTarget
Returns the formtarget attribute value.The formtarget attribute overrides the
targetattribute of the parent form for this specific submit button. Used on<input type="submit">and<input type="image">elements. Values include"_self","_blank","_parent", and"_top".- Returns:
- The form target, or
nullif not set.
-
getName
Returns the name attribute value.- Returns:
- the input name, or null if not set
-
getValue
Returns the current value of the input.- Returns:
- the current value
-
onValueInitialized
Called when the value is first initialized from the client.- Parameters:
value- the initial value from the clientstate- the initial state information
-
onValueUpdate
Called when the value is updated from the client.- Parameters:
value- the new value from the clientstate- the current state information
-
onValueChange
protected void onValueChange()Called when the input value changes. Override to handle value change events. -
reset
public boolean reset()Resets the input value to its initial value.- Returns:
- true if the value was changed, false if already at initial value
-
associateLabel
Associates this input with a label element.Creates a proper label-input binding for accessibility. Screen readers will announce the label text when the input receives focus.
- Parameters:
label- The Label element to associate with this input.- Returns:
- This element for method chaining.
-
setErrorDisplay
Sets up an accessible error display for this input.Associates an element that will contain error messages for this input. When aria-invalid is set to true, screen readers will announce the error message.
Usage:
TextInput email = new TextInput(); Span errorSpan = new Span(); errorSpan.setId("email-error"); email.setErrorDisplay(errorSpan); // When validation fails: email.setHasError(true); errorSpan.setText("Please enter a valid email address");- Parameters:
errorElement- The element that will contain error messages.- Returns:
- This element for method chaining.
-
setHasError
Marks this input as having or not having an error.Sets aria-invalid appropriately and should be used in conjunction with an error display element configured via
setErrorDisplay(Element).- Parameters:
hasError- True if the input has a validation error.- Returns:
- This element for method chaining.
-
setDescription
Associates this input with an element providing additional description.The referenced element's text will be announced by screen readers after the input's label, providing additional context or instructions.
Usage:
TextInput password = new TextInput(); Span hint = new Span("Password must be at least 8 characters"); hint.setId("password-hint"); password.setDescription(hint);- Parameters:
descriptionElement- The element containing the description text.- Returns:
- This element for method chaining.
-
setRequiredAccessible
Sets this input as required with proper accessibility attributes.Sets both the HTML5 required attribute and aria-required for screen readers.
- Parameters:
required- True if the input is required.- Returns:
- This element for method chaining.
-