Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Form autofilling in vaadin
Hello guys, actually I am new to vaadin and i want to enable form autofill feature to all my input fields on the form which shows me the recent values entered in the input field. I tried a lot but couldn't find any solution. Can any one suggest me?
What you are talking about is a browser feature. Recently used values are stored by the browser when you submit a form, the input values are linked by the field's name. In Vaadin, forms are not "submitted" like in traditional web applications nor do input fields have the "name" attribute, so this can actually be quite hard to achieve.
It is possible to mimic the functionality - but only in a limited way. The only thing that pops into my mind is to store user input values manually into cookies/local storage/database and then use those values to populate an autocomplete box using an add-on such as the autocomplete (disclaimer, it's a 3rd party add-on which I haven't tried out myself). This will give you somewhat the functionality you are looking for, but it will only work for values you've inputed in your application and it's quite cumbersome to implement. The browser feature uses values entered on other web sites and not just in your, but the approach I've suggested will only be able to autocomplete values you've used in your application.
Hey Kim, thanks for the suggestion but i wanted the autofill feature as in the traditional web applications in vaadin and not the one which retrieves the data from the database or any other local resource.
I am also trying to get my (non-login) forms to autocomplete based on the browser's local history.
Is there a better solution than manually storing a cookie and then reading that back in to fill the fields?
As this is quite a basic browser feature, I am surprised this doesn't work out of the box. I am even more confused that I found a Stackoverflow post where a user specifically asks to disable autocomplete. https://stackoverflow.com/questions/26709837/how-to-set-autocomplete-off-in-vaadin
I would prefer a solution in Vaadin 7.7 but might switch to Vaadin 8 earlier if it works there.