Directory

← Back

MoneyField

Field for entering JSR354 javax.money.MonetaryAmounts (including both amount and currency)

Author

Rating

Popularity

500+

MoneyField is a simple field for entering / displaying monetary amounts (amount and currency) bound to a JSR-354 javax.money.MonetaryAmount. The user can enter the amount and select the currency from a drop-down. Developers can select which currencies are available, pre-select a currency, make the currency read-only and even alow the user to enter simple calculations like "(10+12)*1,2". The amount is formatted and rounded according to the locale of the UI.

Icon made by Freepik from Flaticon

Sample code

MoneyField moneyField = new MoneyField();
moneyField.setCurrency("EUR");
FastMoney money = FastMoney.of(100.99, "AED");
List<String> currencies = Arrays.asList("AED", "AFN", "ALL", "AMD", "ANG", "AOA", "ARS"); // see https://en.wikipedia.org/wiki/ISO_4217 

MoneyField moneyField = new MoneyField(money, currencies);
moneyField.setLabel("Amount in currencies starting with A");
moneyField.addThemeVariants(TextFieldVariant.LUMO_ALIGN_RIGHT);
MoneyField amount = new MoneyField("Amount");

Binder<Invoice> binder = new BeanValidationBinder<>(Invoice.class);
binder.forField(amount).asRequired().bind(Invoice::getAmount, Invoice::setAmount);
// alternatively: binder.bindInstanceFields(this);
MoneyField moneyField = new MoneyField("Amount", true);
MoneyField money = new MoneyField("Amount", "EUR");
money.setCurrencyReadOnly(true);

Compatibility

(Loading compatibility data...)

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

updated dependencies, fixed bug when clearing the moneyfield

Released
2023-12-01
Maturity
BETA
License
Apache License 2.0

Compatibility

Framework
Vaadin 23+
Vaadin 21+ in 1.0.2
Browser
N/A

MoneyField - Vaadin Add-on Directory

Field for entering JSR354 javax.money.MonetaryAmounts (including both amount and currency) MoneyField - Vaadin Add-on Directory
MoneyField is a simple field for entering / displaying monetary amounts (amount and currency) bound to a [JSR-354](https://github.com/JavaMoney/jsr354-api) [javax.money.MonetaryAmount](https://javamoney.github.io/apidocs/javax/money/MonetaryAmount.html). The user can enter the amount and select the currency from a drop-down. Developers can select which currencies are available, pre-select a currency, make the currency read-only and even alow the user to enter simple calculations like "(10+12)*1,2". The amount is formatted and rounded according to the locale of the UI. Icon made by [Freepik](https://www.freepik.com") from [Flaticon](www.flaticon.com)
Online