Class WEmailEdit
This widget directly corresponds to an <input type="email">:
- Values set with
setValueText()or received from the client are automaticallysanitizedaccording to the sanitization algorithm from the HTML specification. - Browsers will automatically perform validation on the input.
- On-screen keyboards should adjust themselves accordingly for email address input.
- Optionally, a
regular expressioncan be configured. - It's possible to enter
multiple comma-separated email addressesif configured.
Upon construction, a WEmailValidator is automatically created and associated with the
WEmailEdit. Changing any of the email edit's properties, like the pattern or whether multiple addresses are enabled, will automatically
cause the associated email validator to be updated and
vice versa.
Note: At the time of writing, Firefox does not do sanitization: https://bugzilla.mozilla.org/show_bug.cgi?id=1518162.
This may cause the browser to add the :invalid pseudo tag to inputs that are deemed
valid by JWt.
Note: Wt does not do any Punycode encoding or decoding. At the time of writing, if
you put an internationalized email address into a WEmailEdit on Blink-based browsers like
Google Chrome, it will be converted to Punycode by the browser. Firefox and Safari do not do this
encoding, so these email addresses will be deemed invalid by the WEmailValidator.
-
Nested Class Summary
Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WObject
WObject.FormData -
Field Summary
Fields inherited from class eu.webtoolkit.jwt.WInteractWidget
dragTouchEndSlot_, dragTouchSlot_, noDefaultFields inherited from class eu.webtoolkit.jwt.WWidget
WT_GETEXTRAMS_JS -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new email edit.WEmailEdit(WContainerWidget parentContainer) Creates a new email edit. -
Method Summary
Modifier and TypeMethodDescriptionReturns the associated email validator.Returns the regular expression that email addresses should match.Returns the current value as an UTF-8 string.booleanReturns whether this input accepts multiple comma-separated email addresses.protected voidrender(EnumSet<RenderFlag> flags) Renders the widget.static StringSanitizes the given UTF-8 string, returning an UTF-8 string.voidsetFormData(WObject.FormData formData) voidsetMultiple(boolean multiple) Sets whether this input accepts multiple comma-separated email addresses.voidsetPattern(CharSequence pattern) Sets a regular expression that email addresses should match.voidsetValueText(String value) Sets the value.Event signal emitted when the text in the input field changed.protected voidMethods inherited from class eu.webtoolkit.jwt.WFormWidget
changed, enableAjax, getLabel, getPlaceholderText, getRealValidator, getTabIndex, getValidator, hasValidatorChanged, isCanReceiveFocus, isReadOnly, propagateSetEnabled, refresh, remove, setEnabled, setHidden, setPlaceholderText, setReadOnly, setToolTip, setValidator, validate, validatedMethods inherited from class eu.webtoolkit.jwt.WInteractWidget
clicked, doubleClicked, enterPressed, escapePressed, gestureChanged, gestureEnded, gestureStarted, getMouseOverDelay, isEnabled, keyPressed, keyWentDown, keyWentUp, load, mouseDragged, mouseMoved, mouseWentDown, mouseWentOut, mouseWentOver, mouseWentUp, mouseWheel, setDraggable, setDraggable, setDraggable, setDraggable, setMouseOverDelay, setPopup, touchEnded, touchMoved, touchStarted, unsetDraggableMethods inherited from class eu.webtoolkit.jwt.WWebWidget
addStyleClass, beingDeleted, blurred, callJavaScriptMember, childrenChanged, createDomElement, doJavaScript, escapeText, escapeText, escapeText, escapeText, find, findById, focussed, formDataChanged, getAttributeValue, getBaseZIndex, getChildren, getClearSides, getDecorationStyle, getDomChanges, getFloatSide, getHeight, getHtmlTagName, getId, getJavaScriptMember, getLineHeight, getMargin, getMaximumHeight, getMaximumWidth, getMinimumHeight, getMinimumWidth, getOffset, getPositionScheme, getScrollVisibilityMargin, getStyleClass, getToolTip, getVerticalAlignment, getVerticalAlignmentLength, getWidth, hasFocus, hasStyleClass, hideToolTip, isDisabled, isHidden, isHiddenKeepsGeometry, isInline, isLoaded, isPopup, isRendered, isScrollVisibilityEnabled, isScrollVisible, isSetFirstFocus, isThemeStyleEnabled, isVisible, iterateChildren, jsStringLiteral, jsStringLiteral, manageWidget, parentResized, parentResized, propagateSetVisible, removeScript, removeStyleClass, resendFormData, resize, scrollVisibilityChanged, setAttributeValue, setBaseZIndex, setCanReceiveFocus, setClearSides, setDecorationStyle, setDeferredToolTip, setDisabled, setFlexBox, setFloatSide, setFocus, setHiddenKeepsGeometry, setHtmlTagName, setId, setInline, setJavaScriptMember, setLineHeight, setLoadLaterWhenInvisible, setMargin, setMaximumSize, setMinimumSize, setObjectName, setOffsets, setParentWidget, setPositionScheme, setScrollVisibilityEnabled, setScrollVisibilityMargin, setSelectable, setStyleClass, setTabIndex, setThemeStyleEnabled, setVerticalAlignment, showToolTip, showToolTipOnHover, unescapeText, updateSignalConnection, voidEventSignal, widgetAdded, widgetRemovedMethods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addJSignal, addStyleClass, animateHide, animateShow, applyThemeStyles, boxBorder, boxPadding, createJavaScript, disable, dropEvent, enable, getDropTouch, getJsRef, getParent, hide, htmlText, isExposed, isGlobalWidget, isLayoutSizeAware, layoutSizeChanged, needsRerender, positionAt, positionAt, positionAt, positionAt, removeFromParent, removeStyleClass, removeWidget, render, resize, scheduleRender, scheduleRender, scheduleRender, scheduleThemeStyleApply, setClearSides, setDeferredToolTip, setFocus, setHeight, setHidden, setLayoutSizeAware, setMargin, setMargin, setMargin, setMargin, setMargin, setOffsets, setOffsets, setOffsets, setOffsets, setOffsets, setToolTip, setVerticalAlignment, setWidth, show, stopAcceptDrops, toggleStyleClass, toggleStyleClass, trMethods inherited from class eu.webtoolkit.jwt.WObject
getObjectName
-
Constructor Details
-
WEmailEdit
Creates a new email edit.A default-constructed
WEmailEditwill haveisMultiple()set tofalse, and thegetPattern()set to the empty string (i.e. no pattern).A default-constructed
WEmailValidatorwill be automatically created and associated with thisWEmailEdit. This validator can be unset or changed usingWFormWidget#setValidator(). -
WEmailEdit
public WEmailEdit()Creates a new email edit.
-
-
Method Details
-
getEmailValidator
Returns the associated email validator.If
WFormWidget.getValidator()isnullor not a, this will returnWEmailValidatornull.- See Also:
-
setMultiple
public void setMultiple(boolean multiple) Sets whether this input accepts multiple comma-separated email addresses.- See Also:
-
isMultiple
public boolean isMultiple()Returns whether this input accepts multiple comma-separated email addresses.- See Also:
-
setPattern
Sets a regular expression that email addresses should match.The regular expression is an ECMAScript style regular expression.
- See Also:
-
getPattern
Returns the regular expression that email addresses should match.- See Also:
-
textInput
Event signal emitted when the text in the input field changed.This signal is emitted whenever the text contents has changed. Unlike the
WFormWidget.changed()signal, the signal is fired on every change, not only when the focus is lost. Unlike theWInteractWidget.keyPressed()signal, this signal is fired also for other events that change the text, such as paste actions.- See Also:
-
setValueText
Sets the value.The value will be automatically
sanitized.- Specified by:
setValueTextin classWFormWidget- See Also:
-
getValueText
Returns the current value as an UTF-8 string.- Specified by:
getValueTextin classWFormWidget- See Also:
-
sanitize
Sanitizes the given UTF-8 string, returning an UTF-8 string.The sanitization is performed according to the WHATWG spec:
- If multiple is true, all leading or trailing ASCII whitespace is removed from every email address.
- If multiple is false, all carriage return (
\r) and newline (\n) characters are removed and all leading and trailing ASCII whitespace is removed.
-
setFormData
- Overrides:
setFormDatain classWObject
-
render
Description copied from class:WWidgetRenders the widget.This function renders the widget (or an update for the widget), after this has been scheduled using
scheduleRender().The default implementation will render the widget by serializing changes to JavaScript and HTML. You may want to reimplement this widget if you have been postponing some of the layout / rendering implementation until the latest moment possible. In that case you should make sure you call the base implementation however.
- Overrides:
renderin classWFormWidget
-
validatorChanged
protected void validatorChanged()- Overrides:
validatorChangedin classWFormWidget
-