Class WEmailEdit


  • public class WEmailEdit
    extends WFormWidget
    A widget for inputting email addresses.

    This widget directly corresponds to an <input type="email">:

    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.

    • Method Detail

      • 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()
      • 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.

      • render

        protected void render​(java.util.EnumSet<RenderFlag> flags)
        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 class WFormWidget