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.

clientsideapp-overview.asciidoc 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. ---
  2. title: Overview
  3. order: 1
  4. layout: page
  5. ---
  6. [[clientsideapp.overview]]
  7. = Overview
  8. Vaadin allows developing client-side modules that run in the browser.
  9. Client-side modules can use all the GWT widgets and some Vaadin-specific
  10. widgets, as well as the same themes as server-side Vaadin applications.
  11. Client-side applications run in the browser, even with no further server
  12. communications. When paired with a server-side service to gain access to data
  13. storage and server-side business logic, client-side applications can be
  14. considered "fat clients", in comparison to the "thin client" approach of the
  15. server-side Vaadin applications. The services can use the same back-end services
  16. as server-side Vaadin applications. Fat clients are useful for a range of
  17. purposes when you have a need for highly responsive UI logic, such as for games
  18. or for serving a huge number of clients with possibly stateless server-side
  19. code.
  20. [[figure.clientsideapp.overview.architecture]]
  21. .Client-Side Application Architecture
  22. image::img/clientsideapp-architecture-hi.png[]
  23. A client-side application is defined as a __module__, which has an
  24. __entry-point__ class. Its [methodname]#onModuleLoad()# method is executed when
  25. the JavaScript of the compiled module is loaded in the browser.
  26. Consider the following client-side application:
  27. [source, java]
  28. ----
  29. public class HelloWorld implements EntryPoint {
  30. @Override
  31. public void onModuleLoad() {
  32. RootPanel.get().add(new Label("Hello, world!"));
  33. }
  34. }
  35. ----
  36. The user interface of a client-side application is built under a HTML __root
  37. element__, which can be accessed by [methodname]#RootPanel.get()#. The purpose
  38. and use of the entry-point is documented in more detail in
  39. <<clientsideapp-entrypoint#clientsideapp.entrypoint,"Client-Side
  40. Module Entry-Point">>. The user interface is built from __widgets__
  41. hierarchically, just like with server-side Vaadin UIs. The built-in widgets and
  42. their relationships are catalogued in
  43. <<../clientsidewidgets/clientsidewidgets-overview.asciidoc#clientsidewidgets.overview,"Client-Side
  44. Widgets">>. You can also use many of the widgets in Vaadin add-ons that have
  45. them, or make your own.
  46. A client-side module is defined in a __module descriptor__, as described in
  47. <<../clientside/clientside-module#clientside.module,"Client-Side
  48. Module Descriptor">>. A module is compiled from Java to JavaScript using the
  49. Vaadin Compiler, of which use was described in
  50. <<../clientside/clientside-compiling#clientside.compiling,"Compiling
  51. a Client-Side Module">>. The
  52. <<clientsideapp-compiling#clientsideapp.compiling,"Compiling
  53. and Running a Client-Side Application">> in this chapter gives further
  54. information about compiling client-side applications. The resulting JavaScript
  55. can be loaded to any web page, as described in
  56. <<clientsideapp-loading#clientsideapp.loading,"Loading
  57. a Client-Side Application">>.
  58. // TODO What is this? What's an "UI Binder"?
  59. The client-side user interface can be built declaratively using the included
  60. __UI Binder__.
  61. // , as described in <<clientsideapp.uibinder>>.
  62. The servlet for processing RPC calls from the client-side can be generated
  63. automatically using the included compiler.
  64. Even with regular server-side Vaadin applications, it may be useful to provide
  65. an off-line mode if the connection is closed. An off-line mode can persist data
  66. in a local store in the browser, thereby avoiding the need for server-side
  67. storage, and transmit the data to the server when the connection is again
  68. available. Such a pattern is commonly used with Vaadin TouchKit.
  69. ////
  70. TODO It may be necessary to have such a section at some point.
  71. Use of a client-side application to provide an off-line mode is described in <<clientsideapp.offline>>.
  72. ////