You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

migrating-to-vaadin8.asciidoc 8.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. ---
  2. title: Migrating to Framework 8
  3. order: 1
  4. layout: page
  5. ---
  6. [[migration]]
  7. = Migration from Framework 7 to Framework 8
  8. Most Vaadin Framework 7 applications will need some changes when migrating to Vaadin Framework 8.
  9. To make migration from version 7 to 8 as straightforward as possible, Vaadin Framework 8 ships with compatibility packages that include all the old features and APIs that have changed between versions.
  10. The recommended migration path to take for any non-trivial Vaadin application is to first switch any incompatible components to using the APIs available in the compatibility packages, after which parts of the application can be migrated separately.
  11. This is primarily to get an existing Framework 7 project up and running with Framework 8 as quickly as possible, as well as to avoid having to switch to using completely new APIs throughout an entire project all at once.
  12. === Updating Project Dependencies
  13. The very first step in migration is to ensure that your project is configured to use Framework 8 dependencies, as well as include any of the desired compatibility packages needed in your migration.
  14. Also note that Framework 8 requires JDK 8 for development.
  15. For deployment configurations, refer to the list of supported technologies in the release notes, available at link:https://vaadin.com/download/release/8.0/8.0.0/release-notes.html#supportedversions[].
  16. ==== Updating Maven Dependencies
  17. For maven based projects including compatibility packages is simply a matter of changing the artifactId of the desired non-compatibility dependency to the compatibility variant.
  18. For example in the case of changing the vaadin-server dependency from Framework version 7.7.6 to 8.0.0 would require changing
  19. ```xml
  20. <dependency>
  21. <groupId>com.vaadin</groupId>
  22. <artifactId>vaadin-server</artifactId>
  23. <version>7.7.6</version>
  24. </dependency>
  25. ```
  26. to either
  27. ```xml
  28. <dependency>
  29. <groupId>com.vaadin</groupId>
  30. <artifactId>vaadin-compatibility-server</artifactId>
  31. <version>8.0.0</version>
  32. </dependency>
  33. ```
  34. for including both compatibility features as well as non-compatibility ones, or alternatively
  35. ```xml
  36. <dependency>
  37. <groupId>com.vaadin</groupId>
  38. <artifactId>vaadin-server</artifactId>
  39. <version>8.0.0</version>
  40. </dependency>
  41. ```
  42. to only include Framework 8 features.
  43. The full list of compatibility packages available for Framework 8 are the following:
  44. * vaadin-compatibility-server
  45. * vaadin-compatibility-client
  46. * vaadin-compatibility-client-compiled
  47. * vaadin-compatibility-shared
  48. * vaadin-compatibility-themes
  49. IMPORTANT: The themes Reindeer, Runo, Chameleon and Base have been deprecated in Vaadin Framework 8 and they now reside in the compatibility-themes package.
  50. Applications still using any of these themes must include this package.
  51. ==== Pro Tools
  52. For migration of projects using Vaadin Pro Tools check the following sections:
  53. * <<dummy/../../../charts/java-api/charts-migration-vaadin8.asciidoc#charts4.migration, "Charts 3 to Charts 4 Migration Guide">>
  54. * <<dummy/../../../testbench/testbench-migration.asciidoc#testbench.migration, "TestBench 4 to TestBench 5 Migration Guide">>
  55. * <<dummy/../../../spreadsheet/spreadsheet-migration-vaaadin8.asciidoc#spreadsheet.migration, "Spreadsheet 1 to Spreadsheet 2 Migration Guide">>
  56. ==== Add-ons
  57. As with projects themselves, some addons built for Framework 7 will not be directly compatible with Framework 8, thus any add-on dependencies must also be updated to versions that are compatible with Framework 8.
  58. Be sure to check the add-on directory at link:https://vaadin.com/directory[] for updates to add-ons your project depends on.
  59. For add-on developers, the same steps outlined in this guide can also be applied to upgrading your add-ons from Framework 7 to 8.
  60. === Using The Compatibility Packages
  61. Once your project's dependencies have been updated for Framework 8 migration there are a few steps to begin using the compatibility versions of the old APIs, namely changing of imports and ensuring that your widgetset is correctly set up.
  62. Optionally, if you are using Vaadin Designer or declarative files otherwise, the tag names for compatibility components need to be updated.
  63. ==== The Migration Tool
  64. To ease the migration process, the Vaadin maven plugin has a target `vaadin:upgrade8` which updates all
  65. imports in java files and prefixes in design files to point to the versions in the compatibility packages.
  66. This migration tool is available separately at link:https://github.com/vaadin/framework8-migration-tool[].
  67. ==== Changing Imports
  68. The only change to classes in the compatibility packages is the change in their classpath. All compatibility classes can be found under `com.vaadin.v7.*`.
  69. For example the compatibility `TextField` is available through the import `import com.vaadin.v7.ui.TextField`, given that the project dependencies have been set up to include the compatibility variants, as described in the previous section.
  70. ==== Widgetset Changes
  71. When using compatibility packages in your project you need to changes references from the default Vaadin client side widgetset `com.vaadin.DefaultWidgetSet` to the one containing the compatibility packages `com.vaadin.v7.Vaadin7WidgetSet`, which is available in the vaadin-compatibility-client-compiled maven dependency.
  72. Typically, widgetset recompilation will handle this automatically for you, except for the following two cases which should be handled manually:
  73. * Your project defines a custom widgetset, in which case you need to make sure `Vaadin7WidgetSet` is inherited
  74. * An UI in your project defines its widgetset with the annotation `@Widgetset("com.vaadin.DefaultWidgetSet")`, which should be changed to `@Widgetset("com.vaadin.v7.Vaadin7WidgetSet")`
  75. IMPORTANT: The widgetset compilation for `Vaadin7WidgetSet` requires at least 1G of memory. To ensure this, add
  76. `<extraJvmArgs>-Xmx1G</extraJvmArgs>` to the vaadin-maven-plugin configuration in your `pom.xml` file.
  77. ==== Using Compatibility Components In Declarative Files
  78. Using components from the compatibility packages in your declarative files only requires you to change the prefix from `vaadin-` or alternatively `v-` to `vaadin7-`.
  79. For example, the conversion of a `com.vaadin.ui.TextField`
  80. ```html
  81. <vaadin-text-field _id="textField" />
  82. ```
  83. to its compatibility equivalent, `com.vaadin.v7.ui.TextField`, would simply be achieved with the following replacement
  84. ```html
  85. <vaadin7-text-field _id="textField" />
  86. ```
  87. in the corresponding design html file.
  88. === Next Steps
  89. By replacing incompatible components of your application with ones from the compatibility packages your project should now be in a state where it can be compiled and run.
  90. To get started with using the new Framework 8 features it is now only a matter of replacing the usage of compatibility APIs where desired.
  91. Aside from minor API and default changes at the component level, the largest change in Vaadin Framework 8 is its new data model.
  92. Framework 8 no longer uses `Item`, `Property` nor `Container`.
  93. These building blocks for the old data binding have been deprecated in favor of more Java 8 friendly APIs.
  94. The new data model can be roughly split into three main topics, namely binding data to field components, providing data to listing components and handling selections.
  95. The revised <<../datamodel/datamodel-fields.asciidoc#datamodel.fields, "Binding Components to Data">> chapter is the recommended resource to get started with learning these new concepts.
  96. For migration from Framework 7 the key references are the following sections:
  97. * <<../datamodel/datamodel-fields.asciidoc#datamodel.fields, "Editing Values in Fields">> and <<../datamodel/datamodel-forms.asciidoc#datamodel.forms, "Binding Data to Forms">>, which cover the new data binding concepts that replace `Property` and `FieldGroup`.
  98. * <<../datamodel/datamodel-providers.asciidoc#datamodel.providers, "Showing Many Items in a Listing">>, which covers the new `Container` and `Item` replacement, the `DataProvider`, as well as the associated sorting and filtering APIs.
  99. * And for the new selection APIs, <<../datamodel/datamodel-selection.asciidoc#datamodel.selection, "Selecting Items">>.
  100. For a full list of incompatible changes between Framework 7 and 8, please refer to the _Incompatible or Behavior-altering Changes_ section of the release notes, available at link:https://vaadin.com/download/prerelease/8.0/8.0.0/8.0.0.beta1/release-notes.html#incompatible[].