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: 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.

  • Constructor Details

  • Method Details

    • getEmailValidator

      public WEmailValidator getEmailValidator()
      Returns the associated email validator.

      If WFormWidget.getValidator() is null or not a WEmailValidator, this will return null.

      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

      public void setPattern(CharSequence pattern)
      Sets a regular expression that email addresses should match.

      The regular expression is an ECMAScript style regular expression.

      See Also:
    • getPattern

      public WString getPattern()
      Returns the regular expression that email addresses should match.

      See Also:
    • 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 the WInteractWidget.keyPressed() signal, this signal is fired also for other events that change the text, such as paste actions.

      See Also:
    • setValueText

      public void setValueText(String value)
      Sets the value.

      The value will be automatically sanitized.

      Specified by:
      setValueText in class WFormWidget
      See Also:
    • getValueText

      public String getValueText()
      Returns the current value as an UTF-8 string.

      Specified by:
      getValueText in class WFormWidget
      See Also:
    • sanitize

      public static String sanitize(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)
      setFormData in class WObject
    • render

      protected void render(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.

      render in class WFormWidget
    • validatorChanged

      protected void validatorChanged()
      validatorChanged in class WFormWidget