NumberField (fixed)
Numeric text field with automatic keystroke filtering and validation for integer (123) and decimal numbers (12.3).
Fixed version of the NumberField created by Markus Häcker.
It fixes the bug that manually added validators are ignored in the isValid() function which may lead to successful commits of invalid forms. See issue #3 (https://code.google.com/p/numberfield/issues/detail?id=3).
Sample code
NumberField numField = new NumberField(); // NumberField extends TextField numField.setDecimalAllowed(true); // not just integers (by default, decimals are allowed) numField.setDecimalPrecision(2); // maximum 2 digits after the decimal separator numField.setDecimalSeparator(','); // e.g. 1,5 numField.setDecimalSeparatorAlwaysShown(true); // e.g. 12345 -> 12345, numField.setMinimumFractionDigits(2); // e.g. 123,4 -> 123,40 numField.setGroupingUsed(true); // use grouping (e.g. 12345 -> 12.345) numField.setGroupingSeparator('.'); // use '.' as grouping separator numField.setGroupingSize(3); // 3 digits between grouping separators: 12.345.678 numField.setMinValue(0); // valid values must be >= 0 ... numField.setMaxValue(999.9); // ... and <= 999.9 numField.setErrorText("Invalid number format!"); // feedback message on bad input numField.setNegativeAllowed(false); // prevent negative numbers (defaults to true) numField.setValueIgnoreReadOnly("10"); // set the field's value, regardless whether it is read-only or not numField.removeValidator(); // omit server-side validation
Links
Compatibility
Was this helpful? Need more help?
Leave a comment or a question below. You can also join
the chat on Discord or
ask questions on StackOverflow.
Version
Removed extension "-xylo" from version number since they cause problems with maven 3.
- Released
- 2014-08-27
- Maturity
- BETA
- License
- Apache License 2.0
Compatibility
- Framework
- Vaadin 6.2+
- Browser
- N/A
NumberField (fixed) - Vaadin Add-on Directory
Numeric text field with automatic keystroke filtering and validation for integer (123) and decimal numbers (12.3).Source Code
Original NumberField
NumberField (fixed) version 0.5.3-xylo
* fixed path to widgetset and replaced specific vaadin version with version range in the add-on dependencies
NumberField (fixed) version 0.5.4
Removed extension "-xylo" from version number since they cause problems with maven 3.