Class WPasswordEdit


public class WPasswordEdit extends WLineEdit
A password edit.

A password edit is a line edit where the character are hidden.

The widget corresponds to the HTML <input type="password"> tag.

  • Constructor Details

  • Method Details

    • setMaxLength

      public void setMaxLength(int length)
      Description copied from class: WLineEdit
      Specifies the maximum length of text that can be entered.

      A value <= 0 indicates that there is no limit.

      The default value is -1.

      Overrides:
      setMaxLength in class WLineEdit
    • setNativeControl

      public void setNativeControl(boolean nativeControl)
      Changes whether a native HTML5 control is used.

      When enabled the browser's native attribute for password input (<input type="password">) will be used instead of a validator.

      By default, this option is set to WWebWidget.isDefaultNativeControl(), which is false by default.

      See Also:
    • isNativeControl

      public boolean isNativeControl()
      Returns whether a native HTML5 control is used.

      See Also:
    • setTextVisible

      public void setTextVisible(boolean visible)
      Sets whether the password is shown in clear text.

      When enabled, the input changes its type from "password" to "text", revealing the content of the field.

      The default value is false.

      See Also:
    • isTextVisible

      public boolean isTextVisible()
      Returns whether the password is shown in clear text.

      See Also:
    • setRevealButtonEnabled

      public void setRevealButtonEnabled(boolean enabled)
      Shows or hides a button allowing the user to reveal the password.

      When enabled, a button is shown inside the line edit which toggles the visibility of the password. The toggle happens client-side, without a server round trip, and is reported back with textVisibilityChanged().

      The default value is false.

      Note: The button can only be activated with a pointer device. For a keyboard-accessible toggle, connect your own control to setTextVisible().

      Note: Hiding the button does not hide a password that is currently shown; use setTextVisible() for that.

      See Also:
    • isRevealButtonEnabled

      public boolean isRevealButtonEnabled()
      Returns whether the reveal button is shown.

      See Also:
    • textVisibilityChanged

      public JSignal1<Boolean> textVisibilityChanged()
      Signal emitted when the user toggles the text visibility.

      This is emitted when the visibility of the password is changed with the reveal button. The argument is whether the password is now shown in clear text.

      See Also:
    • setMinLength

      public void setMinLength(int length)
      Specifies the minimum length of text that can be entered.

      The default value is 0.

    • getMinLength

      public int getMinLength()
      Returns the minimum length of text that can be entered.

      See Also:
    • setRequired

      public void setRequired(boolean required)
      Specifies if the password is required.

      If true, the password cannot be empty.

      The default value is true.

    • isRequired

      public boolean isRequired()
      Return if the password is required.

      See Also:
    • setPattern

      public void setPattern(String newPattern)
      Specifies the pattern that the password must match.

      The default value is "".

    • getPattern

      public WString getPattern()
      Return the pattern the password must match.

      See Also:
    • setInvalidTooLongText

      public void setInvalidTooLongText(CharSequence text)
      Sets the message to display when the password is too long.

      The default value is "Password too long".

    • getInvalidTooLongText

      public WString getInvalidTooLongText()
      Returns the message displayed when the password is too long.

      See Also:
    • setInvalidTooShortText

      public void setInvalidTooShortText(CharSequence text)
      Sets the message to display when the password is too small.

      The default value is "Password too small".

    • getInvalidTooShortText

      public WString getInvalidTooShortText()
      Returns the message displayed when the password is too small.

      See Also:
    • setInvalidNoMatchText

      public void setInvalidNoMatchText(CharSequence text)
      Sets the message to display when the password does not match the pattern.

      The default value is "Invalid input".

    • getInvalidNoMatchText

      public WString getInvalidNoMatchText()
      Returns the message displayed when the password does not match the pattern.

      See Also:
    • setInvalidBlankText

      public void setInvalidBlankText(CharSequence text)
      Sets the message to display when the password is empty and required.

      The default value is "This field cannot be empty".

    • getInvalidBlankText

      public WString getInvalidBlankText()
      Returns the message displayed when the password is empty and required.

      See Also:
    • setValidator

      public void setValidator(WValidator validator)
      Description copied from class: WFormWidget
      Sets a validator for this field.

      The validator is used to validate the current input.

      The default value is null.

      Overrides:
      setValidator in class WFormWidget
      See Also:
    • getValidator

      public WValidator getValidator()
      Description copied from class: WFormWidget
      Returns the validator.
      Overrides:
      getValidator in class WFormWidget
    • validate

      public ValidationState validate()
      Description copied from class: WFormWidget
      Validates the field.

      Overrides:
      validate in class WLineEdit
      See Also:
    • 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.

      Overrides:
      render in class WLineEdit
    • getType

      protected String getType()
      Overrides:
      getType in class WLineEdit
    • getRealValidator

      protected WValidator getRealValidator()
      Overrides:
      getRealValidator in class WFormWidget