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.

MigratingFromVaadin6ToVaadin7.asciidoc 27KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. ---
  2. title: Migrating From Vaadin 6 To Vaadin 7
  3. order: 34
  4. layout: page
  5. ---
  6. [[migrating-from-vaadin-6-to-vaadin-7]]
  7. = Migrating from Vaadin 6 to Vaadin 7
  8. For migration to Vaadin 7.1,  see
  9. <<MigratingFromVaadin7.0ToVaadin7.1#migrating-from-vaadin-7.0-to-vaadin-7.1,
  10. Migrating From Vaadin 7.0 To Vaadin 7.1>>
  11. [[getting-started]]
  12. Getting Started
  13. ~~~~~~~~~~~~~~~
  14. Most Vaadin 7 APIs are compatible with Vaadin 6, but there are some
  15. changes that affect every application.
  16. Moving to Vaadin 7 brings a number of features designed to make the
  17. lives of developers easier. It is a major version where we could improve
  18. (and break) some parts of the API that have been stagnant and in need of
  19. improvement for years.
  20. Fear not, though, as the vast majority of the API is unchanged or
  21. practically so - many parts even for the last 10 years apart for some
  22. package name changes. While every application requires some migration
  23. steps, the minimal steps needed for many applications are simple enough,
  24. although a few more changes can be useful to benefit from some of the
  25. new features such as improvements to data binding.
  26. The first step is to *update Vaadin libraries*. While Vaadin 6 had a
  27. single JAR and separate GWT JARs, Vaadin 7 is packaged as multiple JARs
  28. that also include GWT. The easiest way to get all you need is to use Ivy
  29. (see below in the section on updating an existing Eclipse project) or
  30. Maven (see below on updating a Maven project). If you are using the latest version of
  31. the Vaadin Eclipse plug-in, upgrading the facet version creates an Ivy
  32. configuration.
  33. The first code change that applies to every Vaadin 6 application
  34. concerns the *com.vaadin.Application* class - it *exists no more*. The
  35. main entry point to your application is now a *com.vaadin.ui.UI*, which
  36. replaces Application and its main window. When switching to UI, you also
  37. get multi-window support out of the box, so bye bye to any old hacks to
  38. make it work. On the flip side, a new UI is created on page reload. If
  39. you prefer to keep the UI state over page reloads in the same way Vaadin
  40. 6 does, just add *@PreserveOnRefresh* annotation on your UI class.
  41. For minimal migration, though, it is possible to replace Application
  42. with *LegacyApplication* and its main Window with *LegacyWindow* and
  43. postpone a little dealing with UIs, but when migrating to UIs, you get
  44. more out of the box. The class *Window* is now only used for
  45. "sub-windows" (windows floating inside the page) , not "browser level"
  46. windows or tabs (the whole web page).
  47. An example should clarify things better than lengthy explanations,
  48. so:Vaadin 6:
  49. [source,java]
  50. ....
  51. package com.example.myexampleproject;
  52. import com.vaadin.Application;
  53. import com.vaadin.ui.*;
  54. public class V6tm1Application extends Application {
  55. @Override
  56. public void init() {
  57. Window mainWindow = new Window("V6tm1 Application");
  58. Label label = new Label("Hello Vaadin!");
  59. mainWindow.addComponent(label);
  60. setMainWindow(mainWindow);
  61. setTheme("mytheme");
  62. }
  63. }
  64. ....
  65. Vaadin 7:
  66. [source,java]
  67. ....
  68. package com.example.myexampleproject;
  69. import com.vaadin.server.VaadinRequest;
  70. import com.vaadin.ui.*;
  71. @Theme("mytheme")
  72. public class MyApplicationUI extends UI {
  73. @Override
  74. protected void init(VaadinRequest request) {
  75. VerticalLayout view = new VerticalLayout();
  76. view.addComponent(new Label("Hello Vaadin!"));
  77. setContent(view);
  78. }
  79. }
  80. ....
  81. In addition, replace `com.vaadin.terminal.gwt.server.ApplicationServlet`
  82. with com.vaadin.server.*VaadinServlet* in web.xml and its parameter
  83. "application" with "*UI*" pointing to your UI class, and the application
  84. is ready to go. Likewise, *ApplicationPortlet* has become *VaadinPortlet*.
  85. Some package names have also been changed, but a simple import
  86. reorganization in your IDE should take care of this.
  87. If you have a custom theme, import e.g.
  88. "../reindeer/*legacy-styles.css*" instead of "../reindeer/styles.css".
  89. The theme is now selected with an *@Theme* annotation on your UI class
  90. rather than a call to *setTheme()*, the usage should be clear from the
  91. example above.
  92. Most remaining issues should show up as compilation errors and in most
  93. cases should be easy to fix in your IDE.
  94. Now you should be ready to compile your widgetset (if any) and take the
  95. application for a first test drive. If you have customized themes, they
  96. will probably also need other updates - see the section on themes below.
  97. Note that support for some older browser versions - including IE6 and
  98. IE7 - has been dropped in Vaadin 7. If you absolutely need them, Vaadin
  99. 6 will continue to support them until its planned end of life (June
  100. 2014, five years from release of 6.0).
  101. If you have problems with specific topics, see the related sections of
  102. the migration guide.
  103. In case you need more help with the migration, the Vaadin team also
  104. provides https://vaadin.com/services#professionalservices[professional
  105. services].
  106. [[converting-an-eclipse-project]]
  107. Converting an Eclipse project
  108. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  109. If you have an existing Vaadin 6 Eclipse project, the easiest way to get
  110. up and running with Vaadin 7 is to switch to *Ivy for dependency
  111. management*. In the project properties, select Project Facets and change
  112. the Vaadin plug-in version to 7.0. If necessary, upgrade also the Java
  113. and Dynamic Web Module facets. _Make sure you use the latest version of
  114. the *Eclipse plug-in* from the update site
  115. https://vaadin.com/framework/get-started#eclipse for this, and note that currently
  116. installing it also requires that the IvyDE update site is configured. We
  117. will attempt to eliminate this additional complication soon._
  118. Ivy dependency management can also be configured by hand by adding the
  119. files ivy.xml and ivysettings.xml to the root of the project and using
  120. them from Eclipse (with the IvyDE plug-in), Ant or other build system.
  121. For examples of the two files, see e.g.
  122. http://dev.vaadin.com/svn/integration/eclipse/plugins/com.vaadin.integration.eclipse/template/ivy/[here]
  123. and update VAADIN_VERSION in the file ivy.xml.
  124. Note that Vaadin 7 requires *Java version 6* or higher and *servlet
  125. version 2.4* or higher (or portlet 2.0 or higher). If your project is
  126. set up for older versions, update the corresponding facets.
  127. [[converting-a-maven-project]]
  128. Converting a Maven project
  129. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  130. Converting a *Maven* project is usually quite straightforward: replace
  131. the Vaadin dependency with dependencies to the needed Vaadin artifacts,
  132. remove any dependencies on GWT JARs, replace the GWT plug-in with the
  133. Vaadin plug-in and recompile everything. The easiest way to get the
  134. required sections and dependencies is to create a new project from the
  135. vaadin-application-archetype and copy the relevant sections from it to
  136. your project.
  137. Note that Vaadin 7 requires Java version 6 or higher and servlet version
  138. 2.4 or higher (or portlet 2.0 or higher). If your project is set up for
  139. older versions, update the corresponding dependencies and compiler
  140. version.
  141. [[content-for-windows-panels-and-more]]
  142. Content for Windows, Panels and More
  143. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  144. In Vaadin 6, Window, Panel and some other components had a *default
  145. layout* and addComponent() etc. As this often caused confusion and
  146. caused layout problems when unaware of the implicit layout or forgetting
  147. to set its layout parameters, Vaadin 7 now requires *explicitly setting
  148. the content*. See e.g.
  149. <<CreatingABasicApplication#creating-a-basic-application,Creating
  150. a basic application>>
  151. If you want to minimize the impact of this on the look and theme of an
  152. old application, you can reproduce the *old structure* simply by setting
  153. a `VerticalLayout` (with margins enabled) as the content and add your
  154. components to it rather than the Panel/UI/Window.
  155. Note that the class *Window* is now only used for sub-windows, not
  156. browser level windows.
  157. Information related to browser windows in now in *Page*, including
  158. browser window size, URI fragment and page title. Setting the browser
  159. location (redirecting to a URL) can also be performed via Page.
  160. The API for *Notifications* has also changed, static methods
  161. `Notification.show()` are now used instead of `Window.showNotification()`.
  162. The current *UI*, *Page*, *VaadinService*, *VaadinRequest* and *VaadinResponse*
  163. instances are easily accessible using *UI.getCurrent()*,
  164. *Page.getCurrent()* etc. The session can be obtained using
  165. *UI.getSession()* and the request and response are available from
  166. *VaadinService.getCurrent()*. Thus, no more need for an explicit
  167. *ThreadLocal* to keep track of them.
  168. VaadinSession also provides the new entry point for *locking* access to
  169. Vaadin components from *background threads*, replacing the old approach
  170. of synchronizing to the Application instance - see the javadoc for
  171. *VaadinSession.lock()* for more details.
  172. To customize the creation of UIs - for instance to create different UIs
  173. for mobile and desktop devices -
  174. <<CreatingAnApplicationWithDifferentFeaturesForDifferentClients#creating-
  175. an-application-with-different-features-for-different-clients,a
  176. custom UIProvider>> can be used.
  177. [[forms-and-data-binding]]
  178. Forms and Data Binding
  179. ~~~~~~~~~~~~~~~~~~~~~~
  180. What enterprise applications are all about is data, and the data entry
  181. side in Vaadin 6 has been lacking in customizability. While it has been
  182. possible to create arbitrary forms for data input, many situations have
  183. required either bypassing the Form mechanism or using complicated tricks
  184. to customize their layouts etc.
  185. Although *Form* is still there in Vaadin 7 and a lot of old code for
  186. data binding works mostly as is, version 7 brings something better:
  187. * *FieldGroup* supporting *automated data binding*, whether for a hand-designed
  188. form or
  189. <<AutoGeneratingAFormBasedOnABeanVaadin6StyleForm#
  190. auto-generating-a-form-based-on-a-bean-vaadin-6-style,creating the fields automatically>>
  191. * *<<CreatingATextFieldForIntegerOnlyInputWhenNotUsingADataSource#
  192. creating-a-textfield-for-integer-only-input-when-not-using-a-data-source,typed
  193. fields and properties>>*
  194. * *<<CreatingYourOwnConverterForString#creating-your-own-converter-for-string-mytype-conversion,
  195. converters>>*,
  196. both
  197. <<ChangingTheDefaultConvertersForAnApplication#changing-the-default-converters-for-an-application,
  198. automatic via ConverterFactory>> and
  199. <<CreatingATextFieldForIntegerOnlyInputWhenNotUsingADataSource#
  200. creating-a-textfield-for-integer-only-input-when-not-using-a-data-source,explicitly set>>
  201. * improved *validation* (performed on data model values after
  202. conversion) - see e.g.
  203. <<UsingBeanValidationToValidateInput#using-bean-validation-to-validate-input,bean validation example>>
  204. * and more
  205. If you want to keep using the old mechanisms, just note that e.g.
  206. *TextField* now has the type String, and automatic conversions are applied
  207. as well as *validation* performed on values converted to the *data model
  208. type*. You can migrate data entry views form by form.
  209. The ancient *QueryContainer* has been removed, so it is time to switch
  210. to *SQLContainer* or some other container implementation.
  211. If you are using a custom implementation of *Container.Indexed*, there
  212. is one more method to implement - see the javadoc of *getItemIds(int,
  213. int)* for details and a utility making implementing it easy.
  214. *Property.toString()* should not be used to try to get the value of the
  215. property, use *Property.getValue()* instead.
  216. [[add-ons]]
  217. Add-ons
  218. ~~~~~~~
  219. If your project relies on add-ons from Vaadin Directory, note that not
  220. all of them have been updated for Vaadin 7, and a few might only be
  221. compatible with older Vaadin 7 beta versions. *Check the add-ons* you
  222. use before committing to migration.
  223. You may need to click "*Available for 7*" on the add-on page to get the
  224. correct add-on version.
  225. You can see a list of add-ons with a version available for Vaadin 7 using https://vaadin.com/directory/search[the search],
  226. although some of them might only be compatible with older alpha and beta
  227. versions of Vaadin 7 at the moment.
  228. Note also that a handful of add-ons you might have used are now obsolete
  229. as e.g. *CustomField* is integrated in Vaadin 7.
  230. [[widgetset]]
  231. Widgetset
  232. ~~~~~~~~~
  233. As long as you use the *correct version of* the Eclipse or Maven
  234. *plug-in* to compile your widgetset and remove any old GWT libraries
  235. from your classpath, not much changes for widgetsets.
  236. The current default widgetset is *com.vaadin.DefaultWidgetSet* and
  237. should be inherited by custom widgetsets, although
  238. *com.vaadin.terminal.gwt.DefaultWidgetset* still exists for backwards
  239. compatibility. *DefaultWidgetSet* is also used on portals, replacing
  240. *PortalDefaultWidgetSet*.
  241. If you are compiling your widgetset e.g. with Ant, there are some
  242. changes to the class to execute and its parameters. The class and
  243. parameters to use are now "com.google.gwt.dev.Compiler -workDir (working
  244. directory) -war (output directory) (widgetset module name)" with
  245. optional additional optional parameters before the module name.
  246. If you have optimized your widgetset to limit what components to load
  247. initially, see
  248. <<OptimizingTheWidgetSet#optimizing-the-widget-set,this tutorial>> and the
  249. https://vaadin.com/directory/component/widget-set-optimizer[WidgetSet
  250. Optimizer add-on].
  251. [[themes]]
  252. Themes
  253. ~~~~~~
  254. The *HTML5 DOCTYPE* is used by Vaadin 7, which can affect the behavior
  255. of some CSS rules.Vaadin 7 brings a new option to create your themes,
  256. with SCSS syntax of *SASS* supporting *variables, nested blocks and
  257. mix-ins* for easier reuse of definitions etc.
  258. To get your old application running without bigger changes, just import
  259. e.g. "../reindeer/*legacy-styles.css*" instead of
  260. "../reindeer/styles.css" and take the application for a spin. There will
  261. most likely be some changes to be done in your theme, but the main parts
  262. should be there.
  263. The themes also support *mixing components from multiple themes* and
  264. using multiple applications with *different themes on the same page*,
  265. which can be especially useful for portlets. However, these depend on
  266. fully migrating your themes to the SCSS format with a theme name
  267. selector.
  268. To take advantage of the new features, see
  269. <<CreatingAThemeUsingSass#creating-a-theme-using-sass,Creating a theme using Sass>>
  270. and
  271. <<CustomizingComponentThemeWithSass#customizing-component-theme-with-sass,
  272. Customizing component theme with Sass>>.
  273. Note that the SCSS theme needs to be *compiled* to CSS before use - in
  274. development mode, this takes place automatically on the fly whenever the
  275. theme is loaded, but when moving to production mode, you need to run the
  276. theme compiler on it to produce a pre-compiled static theme.
  277. <<WidgetStylingUsingOnlyCSS#widget-styling-using-only-css,CSS can be used to style
  278. components>> somewhat more freely than in Vaadin 6.
  279. The DOM structure of several layouts has changed, which might require
  280. changes to themes for layouts. See also the section on layouts below.
  281. [[navigation]]
  282. Navigation
  283. ~~~~~~~~~~
  284. In addition to low-level support for handling URI fragments Vaadin 7
  285. also provides a higher level *navigation* framework, allowing you to
  286. focus on the content of your views rather than the mechanics of how to
  287. navigate to them.
  288. The best way to get acquainted with the new navigation features is to
  289. check the tutorials on
  290. <<CreatingABookmarkableApplicationWithBackButtonSupport#
  291. creating-a-bookmarkable-application-with-back-button-support,
  292. creating a bookmarkable application>>,
  293. <<UsingParametersWithViews#using-parameters-with-views,using parameters with views>>,
  294. <<AccessControlForViews#access-control-for-views,access control for views>> and
  295. <<ViewChangeConfirmations#view-change-confirmations,view change confirmations>>.
  296. When logging out a user, you can use *Page.setLocation()* to redirect
  297. the user to a suitable page.
  298. [[extending-the-servlet]]
  299. Extending the Servlet
  300. ~~~~~~~~~~~~~~~~~~~~~
  301. As ApplicationServlet moved to history and is replaced by
  302. *VaadinServlet*, many customizations you have made to it need a rewrite.
  303. The most common customizations:
  304. * <<CustomizingTheStartupPageInAnApplication#customizing-the-startup-page-in-an-application,
  305. Customizing the bootstrap page in an application>>: JavaScript, headers, ...
  306. * Add-ons using customized servlets for other purposes (e.g. customizing
  307. communication between client and server) probably need more extensive
  308. rework
  309. Note also that *TransactionListener*, *ServletRequestListener* and
  310. *PortletRequestListener* have been removed.
  311. Many things that used to be taken care of by *ApplicationServlet* are now
  312. distributed among *VaadinServletService*, *VaadinSession*, *VaadinService*
  313. etc. You can get a *VaadinSession* with *Component.getSession()* and
  314. *VaadinService* e.g. with *VaadinSession.getService()*.
  315. System messages that used to be configured by "overriding" a static
  316. method *Application.getSystemMessages()* are now set in *VaadinService*
  317. using a *SystemMessagesProvider*.
  318. [[client-side-widgets]]
  319. Client side widgets
  320. ~~~~~~~~~~~~~~~~~~~
  321. For add-on authors and creators of custom widgets, the biggest changes
  322. in Vaadin 7 have perhaps taken place on the client side and in
  323. client-server communication.
  324. The first big change is a separation of the client side UI *widgets* and
  325. the code handling communication with the server (*Connector*). The
  326. familiar VLabel is still the client side widget corresponding to the
  327. server side component Label, but the communication part has been split
  328. off into LabelConnector. The annotations linking the client side and the
  329. server side have also changed, now the LabelConnector has an *@Connect*
  330. annotation linking it to the server side component Label.
  331. https://vaadin.com/book/vaadin7/-/page/architecture.client-side.html[The
  332. book] provides some background and the tutorial on
  333. <<CreatingASimpleComponent#creating-a-simple-component,creating a simple
  334. component>> shows an example.
  335. The connector communicates with the server primarily via shared
  336. state from the server to the client and **RPC
  337. calls **<<SendingEventsFromTheClientToTheServerUsingRPC#
  338. sending-events-from-the-client-to-the-server-using-RPC,from
  339. client to server>> and
  340. <<UsingRPCToSendEventsToTheClient#using-rpc-to-send-events-to-the-client,
  341. from server to client>>, with a larger set of supported data types. For
  342. component containers,
  343. <<CreatingASimpleComponentContainer#creating-a-simple-component-container,
  344. the hierarchy of the contained components is sent separately>>.
  345. The old mechanism with UIDL, *paintContent()* and *changeVariables()* is
  346. still there for a while to ease migration, but it is recommended to
  347. update your components to the new mechanisms, which also tend to result
  348. in much cleaner code. Using the old mechanisms requires implementing
  349. *LegacyComponent*.
  350. There are also new features such as support for *Extensions* (components
  351. which
  352. <<CreatingAUIExtension#creating-a-ui-extension,extend the UI>> or
  353. <<CreatingAComponentExtension#creating-a-component-extension,other
  354. components>> without having a widget in a layout) and
  355. <<UsingAJavaScriptLibraryOrAStyleSheetInAnAddOn#
  356. using-a-javascript-library-or-a-style-sheet-in-an-addon,support for
  357. JavaScript>>, also for
  358. <<IntegratingAJavaScriptComponent#integrating-a-javascript-component,
  359. implementing components>> and
  360. <<IntegratingAJavaScriptLibraryAsAnExtension#
  361. integrating-a-javascript-library-as-an-extension,extensions>>,
  362. which might simplify the implementation of some components. Shared state
  363. and RPC can also be used from JavaScript, and there are other techniques
  364. for client-server communication.
  365. *Package names* for the client side have changed but a simple import
  366. reorganization by the IDE should be able to take care of that, the new
  367. packages are under *com.vaadin.client.ui*.
  368. If you have implemented a *component that contains other components*
  369. (HasComponents, ComponentContainer) or have client side widgets which do
  370. size calculations etc, see the layouts chapter - these should now be
  371. much simpler to implement than previously, although much of custom
  372. layout widgets will probably need to be rewritten.
  373. A final note about client side development:
  374. *https://vaadin.com/blog/vaadin-and-superdevmode[SuperDevMode]*
  375. has been integrated to Vaadin 7, eliminating the need for browser
  376. plug-ins in many cases when debugging client side code.
  377. [[migration-steps-quick-and-dirty]]
  378. Migration steps (quick and dirty)
  379. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  380. * Create a connector class for the add-on
  381. * Extend *LegacyConnector*, override the *getWidget()* method, change its
  382. signature to return *VMyWidget* and implement it as return *(VMyWidget)
  383. super.getWidget();*
  384. * Replace the *@ClientWidget(VMyWidget.class)* annotation (on the
  385. server-side component) with *@Connect(MyServerSideComponent.class)* on the
  386. connector class
  387. * Remove the call to *super.updateFromUIDL(...)* in
  388. *VMyWidget.updateFromUIDL(...)* if no such method exists in the
  389. superclass.
  390. * If the widget has implemented *setHeight* and *setWidth*, make the
  391. connector implement *SimpleManagedLayout* and move the layout logic to the
  392. *layout()* method.
  393. * The actual sizes of the widget is available through
  394. *getLayoutManager().getOuterHeight(getWidget().getElement())* and similar
  395. for the width.
  396. * If the widget implements *ContainerResizedListener*, make the connector
  397. implement *SimpleManagedLayout* and call *getWidget().iLayout()* from the
  398. *layout()* method.
  399. * Be prepared for problems if you are doing layouting in *updateFromUIDL*
  400. as the actual size of a relatively sized widget will most likely change
  401. during the layout phase, i.e. after *updateFromUIDL*
  402. The connector class should look like
  403. [source,java]
  404. ....
  405. @Connect(MyComponent.class)
  406. public class MyConnector extends LegacyConnector {
  407. @Override
  408. public VMyWidget getWidget() {
  409. return (VMyWidget) super.getWidget();
  410. }
  411. }
  412. ....
  413. * Implement the interface *LegacyComponent* in the server side class
  414. * If your widget has not delegated caption handling to the framework
  415. (i.e. used *ApplicationConnection.updateComponent(..., ..., false)* you
  416. should override *delegateCaptionHandling()* in your connector and return
  417. false. Please note, however, that this is not recommended for most
  418. widgets.
  419. [[basic-widget-add-on-using-vaadin-7-apis]]
  420. Basic widget add-on using Vaadin 7 APIs
  421. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  422. Note: migration to new communication mechanisms etc. should be performed
  423. step by step.These instructions continue from where the quick and dirty
  424. migration ended.
  425. * Intermediate step: move *updateFromUIDL(...)* implementation from the
  426. widget to the connector
  427. * Change the visibility of any methods and fields it accesses in the
  428. widget to "package"
  429. * Intermediate step: design an API for the widget that does not access
  430. Vaadin communication mechanisms directly
  431. * Use listeners for events from the widget to the server
  432. * Use setters and action methods for server to client modifications
  433. * Convert state variables and their transmission in
  434. *paintContent()*/*updateFromUIDL()* to use shared state
  435. * Convert one-time actions (events etc.) to use RPC
  436. * Remove "implements LegacyComponent" from the server-side class and the
  437. methods *paintContent()* and *changeVariables()*
  438. * Remove "implements Paintable" or "extends LegacyConnector" and
  439. *updateFromUIDL()* from the client-side connector class (extend
  440. *AbstractComponentConnector* instead of *LegacyConnector*)
  441. [[layouts-and-component-containers]]
  442. Layouts and Component Containers
  443. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  444. While the server side API of various layouts has not changed much, the
  445. implementations on the client side have. With the currently supported
  446. browsers, much more can now be calculated by the browser, so Vaadin
  447. layouts often do not need to measure and calculate sizes.
  448. Most of the differences are only relevant to those who develop client
  449. side component containers, but a few can also affect other developers.
  450. Among the changes affecting others than layout developers, *CssLayout*
  451. now consists of a single DIV instead of three nested elements, and
  452. <<WidgetStylingUsingOnlyCSS#widget-styling-using-only-css,CSS
  453. can be used to do more customization>> than in previous Vaadin versions.
  454. Also other layouts have changed in terms of their *DOM structure* on the
  455. client, which might require changes to themes. The interface
  456. *MarginHandler* is now only implemented by layouts that actually support
  457. it, not in *AbstractLayout*, and *margins* should be set in CSS for
  458. *CssLayout*.
  459. When implementing components that are not full-blown layouts (with
  460. *addComponent()*, *removeComponent()* etc.) but should contain other
  461. components, the simpler interface *HasComponents* should be used instead
  462. of *ComponentContainer*.
  463. For those implementing new component containers or layouts, see the
  464. related tutorials
  465. <<CreatingASimpleComponentContainer#creating-a-simple-component-container,
  466. Creating a simple component container>> and
  467. <<WidgetStylingUsingOnlyCSS#widget-styling-using-only-css,
  468. Widget styling using only CSS>>.
  469. [[migration-steps-for-componentcontainers]]
  470. Migration steps for ComponentContainers
  471. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  472. These continue from where the add-on migration steps above left off
  473. * Component containers (e.g. layouts) require more changes as the
  474. underlying layout mechanisms and updates have changed
  475. * Client-side child connectors are now created by the framework
  476. * Hierarchy change events. Guaranteed to run before child calls
  477. *updateCaption*. Create any child slots here and attach the widget.
  478. * Don't paint children
  479. * Don't call *child.updateFromUidl*
  480. * Update caption management (called before *updateFromUidl*, from state
  481. change event listener)
  482. [[miscellaneous-changes]]
  483. Miscellaneous Changes
  484. ~~~~~~~~~~~~~~~~~~~~~
  485. Many overloaded *addListener()* methods have been deprecated. Use
  486. *addClickListener()*, *addValueChangeListener()* etc. instead of them,
  487. reducing ambiguity and the need for explicit casts.
  488. Many *constants* have been replaced with enums, although in most cases
  489. the old names refer to enum values to ease migration.
  490. If using *background threads, locking* has changed: there is no longer
  491. an *Application* class to synchronize to, but *getSession().lock()* etc.
  492. should be used - see the javadoc for details on its correct use, using a
  493. correct try-finally is crucial for building reliable multi-threaded
  494. Vaadin applications.
  495. *ApplicationResource* has been replaced with *ConnectorResource*, taking
  496. different parameters.
  497. *URIHandler* has been replaced with *RequestHandler*. See also the related
  498. class *DownloadStream*.
  499. *JavaScript* can now be executed using *JavaScript.execute()*.
  500. Various methods that were *deprecated* until 6.8 etc. have been removed,
  501. and some classes and methods have been deprecated. In most of those
  502. cases, the deprecation comment or javadoc indicates what to use as a
  503. replacement.
  504. AbstractComponent.*isEnabled()* and *isVisible()* do not take the state
  505. of the parent component into account, but only inquire the state set for
  506. the component itself. A component inside a disabled component still is
  507. disabled, and one inside an invisible component is not rendered on the
  508. browser.
  509. No information is sent to the browser about components marked as
  510. *invisible* - they simply do not exist from the point of view of the
  511. client.
  512. [[components]]
  513. Components
  514. ~~~~~~~~~~
  515. *Button* is no longer a Field and does not have a constructor that takes
  516. a method name to call, use anonymous inner class instead. Because of
  517. this, *CheckBox* is no longer a Button and uses a *ValueChangeListener*
  518. instead of a *ClickListener*.
  519. *DateField* no longer supports milliseconds and its default resolution
  520. is day.
  521. *Label* now supports converters.
  522. *RichTextArea* custom formatting methods removed, use a
  523. *PropertyFormatter* or a *Converter* instead of overriding formatting
  524. methods.
  525. [[need-help]]
  526. Need help?
  527. ----------
  528. If you need any advice, training or hands on help in migrating your app
  529. to Vaadin 7, please be in touch with sales@vaadin.com. Vaadin team would
  530. be happy to be at your service.