XdevPasswordField

The XdevPasswordField is a single-row input field that automatically replaces all the characters with points and, thus, exclusively allows hidden inputs. However, the XdevPasswordField does not provide any protection during data transfer. If the data transfer is not encrypted via HTTPS, the inputs are converted to plain text and can, therefore, be easily read. The XdevPasswordField is a form component, and it can be persisted via XdevFieldGroup.

Important properties:
  • TextChangeEventMode - Determines when exactly the textChange event is triggered.

    • LAZY - Default setting. The event is triggered only if there is a timeout after the last change. The length of the timeout can be defined in Properties > Misc > TextChangeTimeout.
    • EAGER - The event is triggered at each keystroke.
    • TIMEOUT - The event is triggered only if there is a timeout after the last change.


  • TextChangeTimeout - Defines the length of the timeout, after which the textChange event is triggered, in milliseconds.


Important events:
  • textChange - Is triggered after a brief delay following changes to the content, for example adding or deleting characters. The exact time at which the event is triggered can be defined under Properties > Misc > TextChangeEventMode.

  • Misc 

    • valueChange - Is triggered after changes to the content, mainly by adding or deleting characters, however only if the UI component loses the focus.

Examples:
  • Allocate content - Allocates a text as string to the XdevPasswordField. This may trigger a textChange or valueChange event. 
    This is the simplest type of allocation. However, it is 100% functional only with strings. When this method is used, diverse converters deliver an unsatisfactory output

    passwordField.setValue("Hello 123 !!!");
  • Allocate content - Allocates a specific value to the XdevPasswordField. As an example, a BigDecimal data type for currencies or Double for specific formatting with decimal places, etc.
    When this type of allocation is employed, the delivered converter functions optimally.

    Property<BigDecimal> betrag = new ObjectProperty<BigDecimal>(new BigDecimal(100), BigDecimal.class);
    passwordField.setPropertyDataSource(betrag);

    or

    Property<Double> betrag = new ObjectProperty<Double>(new Double(100), Double.class);
    passwordField.setPropertyDataSource(betrag);
  • Change content - If a property is already allocated to the XdevPasswordField (refer to example 2), the value can be changed directly in the property in this abbreviated form without setting a new data source.

    passwordField.setConvertedValue(200);
  • Read content

    String content = passwordField.getValue();
  • Delete content - Deletes the entire content in XdevPasswordField. This may trigger a textChange or valueChange event.

    passwordField.clear();
  • Set cursor - Set the cursor to a specific position. The position is specified as int value.

    passwordField.setCursorPosition(10);
  • Set focus - Allocates the focus to the XdevPasswordField. This can trigger a focus event, if necessary.

    passwordField.focus();
  • Select content

    passwordField.selectAll();
Go to XdevPasswordField Javadoc
Tips:
  • Convert string to integer - If the content of the XdevPasswordField is an integer, with which you want to calculate further, you must convert the string with the Integer.parseInt(String s) method into an integer. The method accepts only a string with characters. Only the characters + and - at the start of the value are permitted.

    String content = passwordField.getValue();
    Integer value = Integer.parseInt(content);
  • Convert integer to string: When you want to assign an integer to an XdevPasswordField, you must first convert it into a string, e.g. with the Integer.toString(Integer i) method.

    Integer value = 100;
    String content = Integer.toString(value);
     
    passwordField.setValue(content);

XDEV Software Corp. - One Embarcadero Center, San Francisco, CA 94111, US
Copyright © 2015. XDEV Software Corp. All rights reserved.