Class OorianForm<T extends OorianForm<T>>
OorianForm renders a <form> element but intercepts browser submission, sending
form data to the server via the Oorian event system (AJAX, SSE, or WebSocket depending on
the page's communication mode). Unlike a standard HTML Form which performs a page
navigation on submit, OorianForm submits asynchronously, allowing the page to remain
loaded and receive updates.
OorianForm integrates with the Oorian validation framework, providing methods to register
ValidatedInputs and FormValidators, validate fields on submission, and
manage validation state.
Usage Example:
OorianForm form = new OorianForm("loginForm");
form.addElement(new TextInput("username"));
form.addElement(new PasswordInput("password"));
form.addElement(new SubmitButton("Login"));
form.registerListener(this);
- Author:
- Marvin P. Warble Jr.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new OorianForm with Oorian's form submission handler configured.OorianForm(String id) Creates a new OorianForm with the specified ID. -
Method Summary
Modifier and TypeMethodDescriptionfinal TaddFormValidator(FormValidator validator) Adds a form-level validator for cross-field validation.final TaddValidatedInput(ValidatedInput<?> validatedInput) Registers aValidatedInputwith this form.voidClears all validation states and error displays.Returns the list of form-level validators.getValidatedInput(String fieldName) Returns theValidatedInputfor the specified field name.List<ValidatedInput<?>> Returns a list of all registeredValidatedInputs.booleanReturns whether all fields are currently valid.voidHook method called when the form is submitted.voidonSubmit(Parameters parameters) Hook method called on form submission with form parameters.voidregisterListener(FormListener listener) Registers a listener for form submission events.final TremoveFormValidator(FormValidator validator) Removes a form-level validator.final TremoveValidatedInput(String fieldName) Removes aValidatedInputfrom this form by field name.voidsubmit()Submits the form programmatically by sending a FormSubmitCommand to the client.validate()Validates all fields using their current input values.Validates all fields using aFormEvent's parameters.final ValidationResultvalidate(FormEvent event, Class<? extends ValidationGroup>... groups) Validates all fields using aFormEvent's parameters with specific validation groups.validate(Parameters parameters) Validates all fields using the provided parameters.protected final ValidationResultvalidate(Parameters parameters, Class<? extends ValidationGroup>... groups) Validates all fields using the provided parameters with specific validation groups.validateForCreate(FormEvent event) Validates all fields for the Create scenario.validateForDraft(FormEvent event) Validates all fields for the Draft scenario.validateForUpdate(FormEvent event) Validates all fields for the Update scenario.Methods inherited from class com.oorian.html.StyledContainerElement
addElement, addLineOfText, addLineOfText, addLineOfText, addParagraph, addParagraph, addSpacer, addText, addText, addText, addText, insertElement, removeAllElements, removeElement, removeElement, setElement, setText, setText, setText, setTextMethods 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, setDisabled, 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, addLineBreak, 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, 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, removeAttribute, removeAttribute, removeFromParent, requestCallback, requestCallback, requestCallback, requestCallback, resetId, scrollTo, scrollToBottom, scrollToTop, self, sendCommand, sendUpdate, setAccept, setComponent, setDir, setDir, setId, setIs, setItemId, setItemProp, setItemRef, setItemScope, setItemType, setLang, setOnError, setOnLoad, setPage, setParent, setPart, setSlot, setTagName, setTranslate, toString, unregisterListener, update, updateAttributes
-
Constructor Details
-
OorianForm
public OorianForm()Creates a new OorianForm with Oorian's form submission handler configured. -
OorianForm
Creates a new OorianForm with the specified ID.- Parameters:
id- The unique identifier for this form element.
-
-
Method Details
-
registerListener
Registers a listener for form submission events.- Parameters:
listener- The form event listener.
-
addValidatedInput
Registers aValidatedInputwith this form.The input's field name (from
InputElement.getName()) is used as the key for building theValidationContextduring form validation.- Parameters:
validatedInput- The ValidatedInput to register.- Returns:
- This form for method chaining.
-
removeValidatedInput
Removes aValidatedInputfrom this form by field name.- Parameters:
fieldName- The name of the field to remove.- Returns:
- This form for method chaining.
-
addFormValidator
Adds a form-level validator for cross-field validation.- Parameters:
validator- TheFormValidatorto add.- Returns:
- This form for method chaining.
-
removeFormValidator
Removes a form-level validator.- Parameters:
validator- TheFormValidatorto remove.- Returns:
- This form for method chaining.
-
validate
Validates all fields using the provided parameters.This method builds a
ValidationContextfrom theParametersobject and validates all registeredValidatedInputs and form-level validators.- Parameters:
parameters- The Parameters object containing field values.- Returns:
- Combined
ValidationResultfrom all validators.
-
validate
@SafeVarargs protected final ValidationResult validate(Parameters parameters, Class<? extends ValidationGroup>... groups) Validates all fields using the provided parameters with specific validation groups.Only validators belonging to the specified groups (plus the Default group) will be run.
- Parameters:
parameters- The Parameters object containing field values.groups- The validation groups to use.- Returns:
- Combined
ValidationResultfrom matching validators.
-
validate
Validates all fields using their current input values.This method reads values directly from the registered
InputElements and validates allValidatedInputs and form-level validators.- Returns:
- Combined
ValidationResultfrom all validators.
-
validate
Validates all fields using aFormEvent's parameters.This method is intended to be called from a
FormListener's onEvent method. It builds aValidationContextfrom the FormEvent's parameters and validates all registeredValidatedInputs and form-level validators.- Parameters:
event- The FormEvent containing form submission parameters.- Returns:
- Combined
ValidationResultfrom all validators.
-
validate
@SafeVarargs public final ValidationResult validate(FormEvent event, Class<? extends ValidationGroup>... groups) Validates all fields using aFormEvent's parameters with specific validation groups.Only validators belonging to the specified groups (plus the Default group) will be run.
- Parameters:
event- The FormEvent containing form submission parameters.groups- The validation groups to use.- Returns:
- Combined
ValidationResultfrom matching validators.
-
validateForCreate
Validates all fields for the Create scenario.This is a convenience method that validates with the
DefaultGroups.Creategroup.- Parameters:
event- The FormEvent containing form submission parameters.- Returns:
- Combined
ValidationResultfrom Create group validators.
-
validateForUpdate
Validates all fields for the Update scenario.This is a convenience method that validates with the
DefaultGroups.Updategroup.- Parameters:
event- The FormEvent containing form submission parameters.- Returns:
- Combined
ValidationResultfrom Update group validators.
-
validateForDraft
Validates all fields for the Draft scenario.This is a convenience method that validates with the
DefaultGroups.Draftgroup.- Parameters:
event- The FormEvent containing form submission parameters.- Returns:
- Combined
ValidationResultfrom Draft group validators.
-
clearValidation
public void clearValidation()Clears all validation states and error displays. -
isFormValid
public boolean isFormValid()Returns whether all fields are currently valid.This method checks the last validation result for each
ValidatedInput. Returnstrueif no validated inputs have been registered.- Returns:
trueif all fields are valid,falseotherwise.
-
getValidatedInput
Returns theValidatedInputfor the specified field name.- Parameters:
fieldName- The name of the field.- Returns:
- The ValidatedInput, or
nullif not found.
-
getValidatedInputs
Returns a list of all registeredValidatedInputs.- Returns:
- List of ValidatedInput objects, or an empty list if none are registered.
-
getFormValidators
Returns the list of form-level validators.- Returns:
- List of
FormValidatorobjects, or an empty list if none are registered.
-
submit
public void submit()Submits the form programmatically by sending a FormSubmitCommand to the client. -
onFormSubmit
public void onFormSubmit()Hook method called when the form is submitted.Override this method to handle form submission events.
-
onSubmit
Hook method called on form submission with form parameters.Called automatically before the
FormEventis dispatched. Override this method to process form data before event dispatch.- Parameters:
parameters- The submitted form parameters.
-