DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • How To Build a Multi-Zone Java App in Days With Vaadin, YugabyteDB, and Heroku
  • Blink a LED on a Raspberry Pi With Vaadin
  • Improving Backend Performance Part 1/3: Lazy Loading in Vaadin Apps
  • Realistic Test Data Generation for Java Apps

Trending

  • Designing Databases for Distributed Systems
  • Agile Estimation: Techniques and Tips for Success
  • Monkey-Patching in Java
  • REST vs. Message Brokers: Choosing the Right Communication
  1. DZone
  2. Coding
  3. Java
  4. Migrating to Vaadin 8

Migrating to Vaadin 8

Vaadin 8 has a compatibility layer to ensure your work with Vaadin 7 will carry over. If you want to remove it, you'll need to work with the DataBinding API.

Thomas Kratz user avatar by
Thomas Kratz
·
Feb. 06, 17 · Tutorial
Like (4)
Save
Tweet
Share
9.37K Views

Join the DZone community and get the full member experience.

Join For Free

Today I finished my migration of a (small) demo app to the new Vaadin 8 API.

First of all: Vaadin 8 has a compatibility layer. Everything you may have used with Vaadin  7 will still work with Vaadin 8, you just have to change some package names in your import statements. (for example, UI gets ui.v7) and everything will work out of the box with Vaadin 8.

But my goal was to completely remove the compatibility layer. That needed quite a bit of work, as the new DataBinding API focuses on binding bean properties. My app used the PropertySetItem in a bunch of places. To move these, I created backing beans and used the new API.

binder.forField(passwordMatchField)
        .withValidator(PasswordMatchValidatorV8(passwordField))
        .bind(LostPasswordBean::passwordMatch)


This was not too hard, but there was more work to be done, as I had to migrate all of my custom Validator implementations. The new Validator signature tastes better than the v7 one, but changing them introduces even more work:

class PasswordMatchValidatorV8 constructor(private val src: PasswordField) : 
    Validator<String> {

    override fun apply(value: String, ctx: ValueContext): ValidationResult {
        val pw: String = src.value        
        if (pw != value) {
            return ValidationResult.error(NO_MATCH)
        }
        return ValidationResult.ok()
    }

    companion object {
        const val NO_MATCH = "Passwords don't match"    }
}


That did make up for most of the fields. Another place where I had to change the code was the old BeanItemContainer, which I used to bind collections to grids etc. Here we have new API too that looks like this:

grid = Grid()
grid.addColumn{ u -> u.email }.setCaption("Username")
dataProvider = ListDataProvider(users)
grid.dataProvider = dataProvider


That's it. It took me about a day for nine View Classes, but remember I was very slow getting used to the new binding style.

For my personal taste, the new binding API is a great step forward, and it makes heavy use of SAM types. Using it with Kotlin is a breeze. It's is still far away from beeing as powerful as the good old eclipse DAtaBinding API, which is still my personal favorite when it comes to UI data bindings.

Vaadin

Published at DZone with permission of Thomas Kratz. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • How To Build a Multi-Zone Java App in Days With Vaadin, YugabyteDB, and Heroku
  • Blink a LED on a Raspberry Pi With Vaadin
  • Improving Backend Performance Part 1/3: Lazy Loading in Vaadin Apps
  • Realistic Test Data Generation for Java Apps

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: