Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8818607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:08:50+00:00 2026-06-14T05:08:50+00:00

I have a vaadin application that has a form,and i use a beanitem as

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T05:08:51+00:00Added an answer on June 14, 2026 at 5:08 am

    Actually Vaadin behaves correctly, but it follows the magnitude rules (already mentioned by Yogendra Singh) please see an example

    enter image description here

    Please also check the following:

        float value1 = 12.0f;
        float value2 = 123123123;
    
        BeanItem<Float> item1 = new BeanItem<Float>(value1);
        BeanItem<Float> item2 = new BeanItem<Float>(value2);
    
        System.out.println(" result 1: " + item1.getBean());
        System.out.println(" result 2: " + item2.getBean());
    

    Result:

    result 1: 12.0
    result 2: 1.2312312E8
    

    So the correct solution (as I can see it) looks like the following:

    1. Define your own Bean. There is no reason to have a BeanItem wrapping a float value.
    2. Define your PropertyFormatter (example)
    3. Important to note, the one should not return a String instead of the correct data type. It will affect editing, validation, etc.

    PropertyFormatter example:

    /** Integer formatter that accepts empty values. */
    public class LenientIntegerFormatter extends PropertyFormatter {
    
        public LenientIntegerFormatter(Property propertyDataSource) {
            setPropertyDataSource(propertyDataSource);
        }
    
        @Override
        public Object parse(String formattedValue) throws Exception {
            if ("".equals(formattedValue))
                return null;
            else
            return Integer.valueOf(formattedValue);
        }
    
        @Override
        public String format(Object value) {
            if (value == null)
                return "";
    
            return ((Integer) value).toString();
        }
    
        @Override
        public Class<?> getType() {
            return String.class;
        }
    }
    

    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.

    enter image description here

    Chapter 9. Binding Components to Data

    Custom Bean example:

    public class Bean implements Serializable {
        String name;
        float value;
    
        public Bean(String name, float newValue) {
            this.name   = name;
            this.value = newValue;
        }
    
        public String getName() {
            return name;
        }
    
        public void setName(String name) {
            this.name = name;
        }
    
        public float getValue() {
            return value;
        }
    
        public void setValue(float newValue) {
            this.value = newValue;
        }
    }
    

    Just to provide all required insights:

     Bean bean = new Bean("Test", value1);
        BeanItem<Bean> beanItem = new BeanItem<Bean>(bean);
        for(Object propertyId: beanItem.getItemPropertyIds()) {
            System.out.println(" Property: '" + propertyId + 
                               "' value: " + beanItem.getItemProperty(propertyId));
        }
    

    Will print:

    Property: 'name' value: Test
    Property: 'value' value: 12.0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a vaadin application in which I have to use JasperReports.
I use Vaadin framework to create my web application GUI. I have a Vaadin
I have a Java application that has a line of code that says: String
I have a vaadin application that redirect after login to a view with header
I need help in a simple application based on Vaadin. I need to have
I am new to Vaadin. I have created template for my web application in
I have a vaadin form with huge number of fields in it(textbox, select box
In Vaadin's website it says that only Eclipse and NetBeans have fully functional (which
The problem is the folowing: I have to create a panel in Vaadin that
I have developed an application in Grails. It uses Vaadin framework for GUI. It

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.