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.

architecture-overview.asciidoc 7.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. ---
  2. title: Overview
  3. order: 1
  4. layout: page
  5. ---
  6. [[architecture.overview]]
  7. = Overview
  8. Vaadin Framework provides two development models for web applications: for the client-side
  9. (the browser) and for the server-side. The server-driven development model is
  10. the more powerful one, allowing application development solely on the
  11. server-side, by utilizing an AJAX-based Vaadin Client-Side Engine that renders
  12. the user interface in the browser. The client-side model allows developing
  13. widgets and applications in Java, which are compiled to JavaScript and executed
  14. in the browser. The two models can share their UI widgets, themes, and back-end
  15. code and services, and can be mixed together easily.
  16. [[figure.architecture.detailed]]
  17. .Vaadin runtime architecture
  18. image::img/architecture-detailed-hi.png[width=80%, scaledwidth=100%]
  19. <<figure.architecture.detailed>> gives a basic illustration of the client-side
  20. and server-side communications, in a running situation where the page with the
  21. client-side code (engine or application) has been initially loaded in the
  22. browser.
  23. Vaadin Framework consists of a __server-side API__, a __client-side API__, a
  24. horde of __user interface components/widgets__ on the both sides, __themes__ for
  25. controlling the appearance, and a __data model__ that allows binding the
  26. server-side components directly to data. For client-side development, it
  27. includes the Vaadin Compiler, which allows compiling Java to JavaScript.
  28. A server-side Vaadin application runs as a servlet in a Java web server, serving
  29. HTTP requests. The [classname]#VaadinServlet# is normally used as the servlet
  30. class. The servlet receives client requests and inteprets them as events for a
  31. particular user session. Events are associated with user interface components
  32. and delivered to the event listeners defined in the application. If the UI logic
  33. makes changes to the server-side user interface components, the servlet renders
  34. them in the web browser by generating a response. The client-side engine running
  35. in the browser receives the responses and uses them to make any necessary
  36. changes to the page in the browser.
  37. The major parts of the server-driven development architecture and their function
  38. are as follows:
  39. User Interface:: Vaadin applications provide a user interface for the user to interface with the
  40. business logic and data of the application. At technical level, the UI is
  41. realized as a __UI__ class that extends [classname]#com.vaadin.ui.UI#. Its main
  42. task is to create the initial user interface out of UI components and set up
  43. event listeners to handle user input. The UI can then be loaded in the browser
  44. using an URL, or can be embedded to any HTML page. For detailed information
  45. about implementing a [classname]#UI#, see
  46. <<dummy/../../../framework/application/application-overview.asciidoc#application.overview,"Writing
  47. a Server-Side Web Application">>.
  48. +
  49. Please note that the term "UI" is used throughout this book to refer both to the
  50. general UI concept as well as the technical UI class concept.
  51. User Interface Components/Widgets:: ((("component")))
  52. ((("widget")))
  53. ((("field")))
  54. The user interface of a Vaadin application consists of components that are
  55. created and laid out by the application. Each server-side component has a
  56. client-side counterpart, a __widget__, by which it is rendered in the browser
  57. and with which the user interacts. The client-side widgets can also be used by
  58. client-side applications. The server-side components relay these events to the
  59. application logic. Field components that have a value, which the user can view
  60. or edit, can be bound to a data source (see below). For a more detailed
  61. description of the UI component architecture, see
  62. <<dummy/../../../framework/components/components-overview.asciidoc#components.overview,"User
  63. Interface Components">>.
  64. Client-Side Engine:: ((("Client-Side
  65. Engine")))
  66. ((("Google Web
  67. Toolkit")))
  68. ((("HTTP")))
  69. The Client-Side Engine of Vaadin manages the rendering of the UI in the web
  70. browser by employing various client-side __widgets__, counterparts of the
  71. server-side components. It communicates user interaction to the server-side, and
  72. then again renders the changes in the UI. The communications are made using
  73. asynchronous HTTP or HTTPS requests. See
  74. <<dummy/../../../framework/architecture/architecture-client-side#architecture.client-side,"Client-Side
  75. Engine">>.
  76. Vaadin Servlet:: ((("VaadinServlet")))
  77. Server-side Vaadin applications work on top of the Java Servlet API (see
  78. <<dummy/../../../framework/architecture/architecture-technology#architecture.technology.servlet,"Java
  79. Servlets">>). The Vaadin servlet, or more exactly the [classname]#VaadinServlet#
  80. class, receives requests from different clients, determines which user session
  81. they belong to by tracking the sessions with cookies, and delegates the requests
  82. to their corresponding sessions. You can customize the Vaadin servlet by
  83. extending it.
  84. Themes:: ((("theme")))
  85. ((("CSS")))
  86. ((("Sass")))
  87. ((("HTML
  88. templates")))
  89. Vaadin makes a separation between the appearance and component structure of the
  90. user interface. While the UI logic is handled as Java code, the presentation is
  91. defined in __themes__ as CSS or Sass. Vaadin provides a number of default
  92. themes. User themes can, in addition to style sheets, include HTML templates
  93. that define custom layouts and other resources, such as images and fonts. Themes
  94. are discussed in detail in
  95. <<dummy/../../../framework/themes/themes-overview.asciidoc#themes.overview,"Themes">>.
  96. Events:: ((("events")))
  97. Interaction with user interface components creates events, which are first
  98. processed on the client-side by the widgets, then passed all the way through the
  99. HTTP server, Vaadin servlet, and the user interface components to the event
  100. listeners defined in the application. See
  101. <<dummy/../../../framework/architecture/architecture-events#architecture.events,"Events
  102. and Listeners">>.
  103. Server Push:: ((("server
  104. push")))
  105. In addition to the event-driven programming model, Vaadin supports server push,
  106. where the UI changes are pushed directly from the server to the client without a
  107. client request or an event. This makes it possible to update UIs immediately
  108. from other threads and other UIs, without having to wait for a request. See
  109. <<dummy/../../../framework/advanced/advanced-push#advanced.push,"Server Push">>.
  110. Data Binding:: ((("Data
  111. Model")))
  112. ((("Data
  113. Binding")))
  114. In addition to the user interface model, Vaadin provides a __data binding__ API for
  115. associating data presented in field components, such as text fields, check boxes and
  116. selection components, with a data source. Using data binding, the user interface
  117. components can update the application data directly, often without the need for
  118. any control code. For example, you can bind a data grid component to a backend query
  119. response. For a complete overview of the data binding model, please refer to
  120. <<dummy/../../../framework/datamodel/datamodel-overview.asciidoc#datamodel.overview,"Binding
  121. Components to Data">>.
  122. Client-Side Applications:: In addition to server-side web applications, Vaadin supports client-side
  123. application modules, which run in the browser. Client-side modules can use the
  124. same widgets, themes, and back-end services as server-side Vaadin applications.
  125. They are useful when you have a need for highly responsive UI logic, such as for
  126. games or for serving a large number of clients with possibly stateless
  127. server-side code, and for various other purposes, such as offering an off-line
  128. mode for server-side applications. Please see
  129. <<dummy/../../../framework/clientsideapp/clientsideapp-overview.asciidoc#clientsideapp.overview,"Client-Side
  130. Applications">> for further details.
  131. Back-end:: Vaadin is meant for building user interfaces, and it is recommended that other
  132. application layers should be kept separate from the UI. The business logic can
  133. run in the same servlet as the UI code, usually separated at least by a Java
  134. API, possibly as EJBs, or distributed to a remote back-end service. The data
  135. storage is usually distributed to a database management system, and is typically
  136. accessed through a persistence solution, such as JPA.