Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The XdevTextField is a single-row input field and one of the most frequently used form components, which can be persisted via the XdevFieldGroup.

Important properties:
  • Include Page
    Property TextChangeEventMode
    Property TextChangeEventMode
  • Include Page
    Property TextChangeTimeout
    Property TextChangeTimeout

...

  • Allocate content - Allocates a text as string to the XdevTextField. 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.

    Code Block
    languagejava
    themeConfluence
    textField.setValue("Hello 123 !!!");


  • Allocate content - Allocates a specific value to the XdevTextField. 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.

    Code Block
    languagejava
    themeConfluence
    Property<BigDecimal> betrag = new ObjectProperty<BigDecimal>(new BigDecimal(100), BigDecimal.class);
    textField.setPropertyDataSource(betrag);

    or

    Code Block
    languagejava
    themeConfluence
    Property<Double> betrag = new ObjectProperty<Double>(new Double(100), Double.class);
    textField.setPropertyDataSource(betrag);


  • Change content - If a property is already allocated to the XdevTextField (refer to example 2), the value can be changed directly in the property in this abbreviated form without setting a new data source.

    Code Block
    languagejava
    themeConfluence
    textField.setConvertedValue(200);


  • Read content

    Code Block
    languagejava
    themeConfluence
    String content = textField.getValue();


  • Delete content - Deletes the entire content in XdevTextField. This may trigger a textChange or valueChange event

    Code Block
    languagejava
    themeConfluence
    textField.clear();


  • Set cursor - Set the cursor to a specific position. The position is specified as an int value. 

    Code Block
    languagejava
    themeConfluence
    textField.setCursorPosition(10);


  • Set focus: Allocates the focus to the XdevTextField. This can trigger a focus event, if necessary.

    Code Block
    languagejava
    themeConfluence
    textField.focus();


  • Select content

    Code Block
    languagejava
    themeConfluence
    textField.selectAll();


  • Check if the field is empty and or null.

    Code Block
    languagejava
    themeConfluence
    boolean empty = textField.isEmpty();
    		
    if (empty) {
    	doSomething();
    }else {
    	doSomething();
    }


  • Check if anything has changed

    Code Block
    languagejava
    themeConfluence
    boolean modified = textField.isModified();

...


Go to XdevTextField Javadoc
Tips:
  • Convert string to integer: If the content of the XdevTextField 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.  

    Code Block
    languagejava
    themeConfluence
    String content = textField.getValue();
    Integer value = Integer.parseInt(content);


  • Convert integer to string: When you want to assign an integer to an XdevTextField, you must first convert it into a string.

    Code Block
    languagejava
    themeConfluence
    Integer value = 100;
    String content = Integer.toString(value);
     
    textField.setValue(content);


...