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 7.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. ---
  2. title: Migrating to Framework 8
  3. order: 1
  4. layout: page
  5. ---
  6. // TODO: Fix release note links to point to 8.0.0
  7. [[migration]]
  8. == Migration from Framework 7 to Framework 8
  9. Most Vaadin Framework 7 applications will need some changes when migrating to Vaadin Framework 8.
  10. 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.
  11. 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.
  12. 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.
  13. === Updating Project Dependencies
  14. 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.
  15. Also note that Framework 8 requires JDK 8 for development.
  16. For deployment configurations, refer to the list of supported technologies in the release notes, available at link:https://vaadin.com/download/prerelease/8.0/8.0.0/8.0.0.beta1/release-notes.html#supportedversions[].
  17. ==== Updating Maven Dependencies
  18. 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.
  19. For example in the case of changing the vaadin-server dependency from Framework version 7.7.6 to 8.0.0 would require changing
  20. ```xml
  21. <dependency>
  22. <groupId>com.vaadin</groupId>
  23. <artifactId>vaadin-server</artifactId>
  24. <version>7.7.6</version>
  25. </dependency>
  26. ```
  27. to either
  28. ```xml
  29. <dependency>
  30. <groupId>com.vaadin</groupId>
  31. <artifactId>vaadin-compatibility-server</artifactId>
  32. <version>8.0.0</version>
  33. </dependency>
  34. ```
  35. for including both compatibility features as well as non-compatibility ones, or alternatively
  36. ```xml
  37. <dependency>
  38. <groupId>com.vaadin</groupId>
  39. <artifactId>vaadin-server</artifactId>
  40. <version>8.0.0</version>
  41. </dependency>
  42. ```
  43. to only include Framework 8 features.
  44. The full list of compatibility packages available for Framework 8 are the following:
  45. * vaadin-compatibility-server
  46. * vaadin-compatibility-client
  47. * vaadin-compatibility-client-compiled
  48. * vaadin-compatibility-shared
  49. * vaadin-compatibility-themes
  50. IMPORTANT: The themes Reindeer, Runo, Chameleon and Base have been deprecated in Vaadin Framework 8 and they now reside in the compatibility-themes package.
  51. Applications still using any of these themes must include this package.
  52. ==== Add-ons
  53. 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.
  54. Be sure to check the add-on directory at link:https://vaadin.com/directory[] for updates to add-ons your project depends on.
  55. 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.
  56. === Using The Compatibility Packages
  57. 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.
  58. Optionally, if you are using Vaadin Designer or declarative files otherwise, the tag names for compatibility components need to be updated.
  59. ==== Changing Imports
  60. 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.*`.
  61. 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.
  62. ==== Widgetset Changes
  63. 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.
  64. Typically, widgetset recompilation will handle this automatically for you, except for the following two cases which should be handled manually:
  65. * Your project defines a custom widgetset, in which case you need to make sure `Vaadin7WidgetSet` is inherited
  66. * 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")`
  67. ==== Using Compatibility Components In Declarative Files
  68. Using components from the compatibility packages in your declarative files only requires you to change the prefix from `vaadin-` or alternatively `v-` to `vaadin7-`.
  69. For example, the conversion of a `com.vaadin.ui.TextField`
  70. ```html
  71. <vaadin-text-field _id="textField" />
  72. ```
  73. to its compatibility equivalent, `com.vaadin.v7.ui.TextField`, would simply be achieved with the following replacement
  74. ```html
  75. <vaadin7-text-field _id="textField" />
  76. ```
  77. in the corresponding design html file.
  78. ==== The Migration Tool
  79. To ease the process of the initial changing of imports and prefixes in design files, a tool for automatically applying these changes to a project is available at link:https://github.com/vaadin/framework8-migration-tool[].
  80. Please refer to the README available in the repository for up to date instructions on how to run the tool on your project.
  81. === Next Steps
  82. 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.
  83. 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.
  84. Aside from minor API and default changes at the component level, the largest change in Vaadin Framework 8 is its new data model.
  85. Framework 8 no longer uses `Item`, `Property` nor `Container`.
  86. These building blocks for the old data binding have been deprecated in favor of more Java 8 friendly APIs.
  87. 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.
  88. The revised <<dummy/../../../framework/datamodel/datamodel-fields.asciidoc, "Binding Components to Data">> chapter is the recommended resource to get started with learning these new concepts.
  89. For migration from Framework 7 the key references are the following sections:
  90. * <<dummy/../../../framework/datamodel/datamodel-fields.asciidoc, "Editing Values in Fields">> and <<dummy/../../../framework/datamodel/datamodel-forms.asciidoc, "Binding Data to Forms">>, which cover the new data binding concepts that replace `Property` and `FieldGroup`.
  91. * <<dummy/../../../framework/datamodel/datamodel-providers.asciidoc, "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.
  92. * And for the new selection APIs, <<dummy/../../../framework/datamodel/datamodel-selection.asciidoc, "Selecting Items">>.
  93. 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[].