Class WEmailEdit
This widget directly corresponds to an <input type="email">
:
- Values set with
setValueText()
or received from the client are automaticallysanitized
according 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 expression
can be configured. - It's possible to enter
multiple comma-separated email addresses
if 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_
-
Constructor Summary
ConstructorDescriptionCreates 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.boolean
Returns whether this input accepts multiple comma-separated email addresses.protected void
render
(EnumSet<RenderFlag> flags) Renders the widget.static String
Sanitizes the given UTF-8 string, returning an UTF-8 string.void
setFormData
(WObject.FormData formData) void
setMultiple
(boolean multiple) Sets whether this input accepts multiple comma-separated email addresses.void
setPattern
(CharSequence pattern) Sets a regular expression that email addresses should match.void
setValueText
(String value) Sets the value.Event signal emitted when the text in the input field changed.protected void
Methods inherited from class eu.webtoolkit.jwt.WFormWidget
changed, enableAjax, getLabel, getPlaceholderText, getTabIndex, getValidator, isCanReceiveFocus, isReadOnly, propagateSetEnabled, refresh, remove, setEnabled, setHidden, setPlaceholderText, setReadOnly, setToolTip, setValidator, validate, validated
Methods 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, unsetDraggable
Methods inherited from class eu.webtoolkit.jwt.WWebWidget
addStyleClass, beingDeleted, blurred, callJavaScriptMember, childrenChanged, createDomElement, doJavaScript, escapeText, escapeText, escapeText, escapeText, find, findById, focussed, 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, isDisabled, isHidden, isHiddenKeepsGeometry, isInline, isLoaded, isPopup, isRendered, isScrollVisibilityEnabled, isScrollVisible, isSetFirstFocus, isThemeStyleEnabled, isVisible, iterateChildren, jsStringLiteral, jsStringLiteral, manageWidget, parentResized, parentResized, propagateSetVisible, removeScript, removeStyleClass, 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, unescapeText, updateSignalConnection, voidEventSignal, widgetAdded, widgetRemoved
Methods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addJSignal, addStyleClass, animateHide, animateShow, boxBorder, boxPadding, createJavaScript, disable, dropEvent, enable, getDropTouch, getJsRef, getParent, hide, htmlText, isExposed, isGlobalWidget, isLayoutSizeAware, layoutSizeChanged, needsRerender, positionAt, positionAt, removeFromParent, removeStyleClass, removeWidget, render, resize, scheduleRender, scheduleRender, scheduleRender, setClearSides, setDeferredToolTip, setFocus, setHeight, setHidden, setLayoutSizeAware, setMargin, setMargin, setMargin, setMargin, setMargin, setOffsets, setOffsets, setOffsets, setOffsets, setOffsets, setToolTip, setVerticalAlignment, setWidth, show, stopAcceptDrops, toggleStyleClass, toggleStyleClass, tr
Methods inherited from class eu.webtoolkit.jwt.WObject
getObjectName
-
Constructor Details
-
WEmailEdit
Creates a new email edit.A default-constructed
WEmailEdit
will haveisMultiple()
set tofalse
, and thegetPattern()
set to the empty string (i.e. no pattern).A default-constructed
WEmailValidator
will 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()
isnull
or not aWEmailValidator
null
. -
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. -
setValueText
Sets the value.The value will be automatically
sanitized
.- Specified by:
setValueText
in classWFormWidget
- See Also:
-
getValueText
Returns the current value as an UTF-8 string.- Specified by:
getValueText
in 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:
setFormData
in classWObject
-
render
Description copied from class:WWidget
Renders 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:
render
in classWFormWidget
-
validatorChanged
protected void validatorChanged()- Overrides:
validatorChanged
in classWFormWidget
-