setting value of a Number Field with stepper

Hello,
I have a form with several Number Fields with stepper enabled.
when I initialize them with

widget.setValue(10d);

the widget shows the right number, 10.
If I have an object with a Double field, value = 10.0 and try to set value in widget

widget.setValue(myObject.getDoubleField());

the widget shows 10,0
how to fix this?

I’m not sure what do you want to fix here, removing the decimal part?

Thomas Mattsson:
I’m not sure what do you want to fix here, removing the decimal part?

Yes, I want the widget to show 10 and not 10,0

This looks to be a formatting bug, I created a ticket for it:
https://github.com/vaadin/vaadin-text-field-flow/issues/172

The field deals exclusively with doubles, so the value does technically always have a decimal part. There is a ticket for creating an IntegerField too: https://github.com/vaadin/vaadin-text-field-flow/issues/151

Thomas Mattsson:
This looks to be a formatting bug, I created a ticket for it:
https://github.com/vaadin/vaadin-text-field-flow/issues/172

The field deals exclusively with doubles, so the value does technically always have a decimal part. There is a ticket for creating an IntegerField too: https://github.com/vaadin/vaadin-text-field-flow/issues/151

thank you

Good to know I’m not the only person this is giving a headache. In a really old version of this component there was a method to disable decimal numbers so that it would do exactly what you are asking about. Not sure why they didn’t implement it in this version or simply have an overloaded version that accepts integers instead of doubles. I’m trying to use it for a zip code field in a Grid (which is an int in my PostgreSQL db) but I had to make it a double in my Java class and it looks really goofy with the trailing decimal. :smiley:

Kevin Palembas:
Good to know I’m not the only person this is giving a headache. In a really old version of this component there was a method to disable decimal numbers so that it would do exactly what you are asking about. Not sure why they didn’t implement it in this version or simply have an overloaded version that accepts integers instead of doubles. I’m trying to use it for a zip code field in a Grid (which is an int in my PostgreSQL db) but I had to make it a double in my Java class and it looks really goofy with the trailing decimal. :smiley:

Kevin, you may be aware of this already, but if its ever a possibility that you can have zip/postal cides from other countries, an int wont work as some countries has characters in the zip codes. 5+4 zip codes may also be an issue.