I have a vaadin application that has a form,and i use a beanitem as a data source.
Inside the beanitem i have a float value that defaults to 0.0..
If i enter a high value like 123123123 and commit(it saves to a db),when i try to edit that field inside the form i get 1.23123123E9 as a value,why?
When i edit i still pass the beanitem with the data in it,why doesn’t it show my value correctly inside the textfield?
I know if i must display the value i can use decimal format but this is inside the form,and vaadin knows it is a float,so it should handle it accordingly right?
Or must i format it inside the form field factory myself?
PS:How can you set a display mode for the values inside the form?I have read you could implement the get of the field inside the bean and have it return a string too,is that the right way to do it?
Actually Vaadin behaves correctly, but it follows the magnitude rules (already mentioned by Yogendra Singh) please see an example
Please also check the following:
Result:
So the correct solution (as I can see it) looks like the following:
PropertyFormatter example:
It may look a little bit scary, but this is the cost of flexibility. Custom Bean allows to use table view, forms, etc without any significant changes. Basically, this is the data model behind Vaadin UI.
Chapter 9. Binding Components to Data
Custom Bean example:
Just to provide all required insights:
Will print: