Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to programmatically set value #60

Open
jonasrotilli opened this issue Jul 11, 2022 · 2 comments
Open

How to programmatically set value #60

jonasrotilli opened this issue Jul 11, 2022 · 2 comments

Comments

@jonasrotilli
Copy link

jonasrotilli commented Jul 11, 2022

I have a text field that uses Numeral. When the user types, everything works perfectly.
When I try to programmatically put a value, the formatting is not done.
What's the secret for it to correct the formatting after I set a value?
Example:

TextField textTest= new TextField("Test");
new NumeralFieldFormatter(".", ",", 3).extend(textTest);

//If I set a value:
textTest.setValue("1234.4");

It's not formatted, it's only if the user modifies anything.

I use in Vaadin 23.

@jonasrotilli
Copy link
Author

Nobody knows?

@mrgreywater
Copy link

mrgreywater commented Jul 7, 2023

my workaround:

    textField.addValueChangeListener(event -> {
        if (!event.isFromClient()) {
            event.getSource().getElement().executeJs("this.querySelector(\"jh-textfield-formatter\").cleave.onInput(\"" + StringEscapeUtils.escapeJava(event.getValue()) + "\");");
        }
    });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants