Class WEmailEdit
- java.lang.Object
-
public class WEmailEdit extends WFormWidget
A widget for inputting email addresses.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
WEmailValidatoris automatically created and associated with theWEmailEdit. Changing any of the email edit's properties, like thepatternor whethermultiple addressesare enabled, will automatically cause the associatedemail validatorto 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
:invalidpseudo 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
WEmailEditon 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 theWEmailValidator. - Values set with
-
-
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_, noDefault
-
Fields inherited from class eu.webtoolkit.jwt.WWidget
WT_GETEXTRAMS_JS
-
-
Constructor Summary
Constructors Constructor Description WEmailEdit()Creates a new email edit.WEmailEdit(WContainerWidget parentContainer)Creates a new email edit.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description WEmailValidatorgetEmailValidator()Returns the associated email validator.WStringgetPattern()Returns the regular expression that email addresses should match.java.lang.StringgetValueText()Returns the current value as an UTF-8 string.booleanisMultiple()Returns whether this input accepts multiple comma-separated email addresses.protected voidrender(java.util.EnumSet<RenderFlag> flags)Renders the widget.static java.lang.Stringsanitize(java.lang.String input, boolean multiple)Sanitizes 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(java.lang.CharSequence pattern)Sets a regular expression that email addresses should match.voidsetValueText(java.lang.String value)Sets the value.EventSignaltextInput()Event signal emitted when the text in the input field changed.protected voidvalidatorChanged()-
Methods 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, 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, hideToolTip, 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, showToolTip, showToolTipOnHover, unescapeText, updateSignalConnection, voidEventSignal, widgetAdded, widgetRemoved
-
Methods 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, tr
-
Methods inherited from class eu.webtoolkit.jwt.WObject
getObjectName
-
-
-
-
Constructor Detail
-
WEmailEdit
public WEmailEdit(WContainerWidget parentContainer)
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 Detail
-
getEmailValidator
public WEmailValidator getEmailValidator()
Returns the associated email validator.If
WFormWidget.getValidator()isnullor not a, this will returnWEmailValidatornull.
-
setMultiple
public void setMultiple(boolean multiple)
Sets whether this input accepts multiple comma-separated email addresses.- See Also:
isMultiple()
-
isMultiple
public boolean isMultiple()
Returns whether this input accepts multiple comma-separated email addresses.- See Also:
setMultiple(boolean multiple)
-
setPattern
public void setPattern(java.lang.CharSequence pattern)
Sets a regular expression that email addresses should match.The regular expression is an ECMAScript style regular expression.
- See Also:
getPattern()
-
getPattern
public WString getPattern()
Returns the regular expression that email addresses should match.- See Also:
setPattern(CharSequence pattern)
-
textInput
public EventSignal 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
public void setValueText(java.lang.String value)
Sets the value.The value will be automatically
sanitized.- Specified by:
setValueTextin classWFormWidget- See Also:
sanitize(String input, boolean multiple)
-
getValueText
public java.lang.String getValueText()
Returns the current value as an UTF-8 string.- Specified by:
getValueTextin classWFormWidget- See Also:
setValueText(String value)
-
sanitize
public static java.lang.String sanitize(java.lang.String input, boolean multiple)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
public void setFormData(WObject.FormData formData)
- Overrides:
setFormDatain classWObject
-
render
protected void render(java.util.EnumSet<RenderFlag> flags)
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
-
-