{"id":76881,"date":"2018-05-15T10:00:39","date_gmt":"2018-05-15T07:00:39","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/?p=76881"},"modified":"2018-05-14T14:54:24","modified_gmt":"2018-05-14T11:54:24","slug":"vaadin-tutorial","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2018\/05\/vaadin-tutorial.html","title":{"rendered":"Vaadin Tutorial"},"content":{"rendered":"<h2 id=\"introduction\">1. Introduction<\/h2>\n<p>When you are a backend developer, you know the pain which is caused when you hear people saying you can&#8217;t create UI pages built-in HTML and can&#8217;t style them in CSS. It&#8217;s like being a backend developer has its known limitations that we can play and run big production backend applications but can&#8217;t make pretty pages which actually show the data managed by those backend applications. If the same idea has ever haunted you, don&#8217;t worry, <a href=\"https:\/\/vaadin.com\/\" target=\"_blank\" rel=\"noopener\">Vaadin<\/a> is here.<\/p>\n<p>With Vaadin, it is possible to create <strong>frontend of your applications purely in Java<\/strong>. It provides a highly mature server-side UI-creation support which allows us to compose production-grade reusable components in Java language. It comes with a support from all popular Java development environments (Eclipse, IntelliJ, NetBeans, Maven, and so on; this tutorial&#8217;s examples use IntelliJ). We will start by understanding how Vaadin actually works and follow with various components and layouts which exists in Vaadin. We will finish the lesson with an excellent sample application which demonstrates event handling and multiple layouts in a single view. Let&#8217;s get started.<\/p>\n<div class=\"toc\">\n<h3>Table Of Contents<\/h3>\n<dl>\n<dt><a href=\"#introduction\">1. Introduction<\/a><\/dt>\n<dt><a href=\"#how_vaadin\">2. How Vaadin works?<\/a><\/dt>\n<dt><a href=\"#plugin\">3. Vaadin Plugins<\/a><\/dt>\n<dt><a href=\"#setup_project\">4. Creating a Project<\/a><\/dt>\n<dt><a href=\"#maven_dependency\">5. Maven Dependencies<\/a><\/dt>\n<dt><a href=\"#vaadin_servlet\">6. Vaadin Servlet<\/a><\/dt>\n<dt><a href=\"#main_class\">7. Vaadin Main Class<\/a><\/dt>\n<dt><a href=\"#layout_mgr\">8. Vaadin Layout Managers<\/a><\/dt>\n<dd>\n<dl>\n<dt><a href=\"#vertical_layout\">8.1 VerticalLayout<\/a><\/dt>\n<dt><a href=\"#horizontal_layout\">8.2 HorizontalLayout<\/a><\/dt>\n<dt><a href=\"#grid_layout\">8.3 GridLayout<\/a><\/dt>\n<dt><a href=\"#form_layout\">8.4 FormLayout<\/a><\/dt>\n<\/dl>\n<\/dd>\n<dt><a href=\"#define_using_task\">9. Vaadin Components<\/a><\/dt>\n<dd>\n<dl>\n<dt><a href=\"#label\">9.1 Label<\/a><\/dt>\n<dt><a href=\"#link\">9.2 Link<\/a><\/dt>\n<dt><a href=\"#textfield\">9.3 TextField<\/a><\/dt>\n<dt><a href=\"#text_area\">9.4 TextArea<\/a><\/dt>\n<dt><a href=\"#date_field\">9.5 DateField and InlineDateField<\/a><\/dt>\n<dt><a href=\"#pwd_field\">9.6 PasswordField<\/a><\/dt>\n<dt><a href=\"#button\">9.7 Button<\/a><\/dt>\n<dt><a href=\"#check_box\">9.8 CheckBox<\/a><\/dt>\n<dt><a href=\"#lists\">9.9 Lists<\/a><\/dt>\n<\/dl>\n<\/dd>\n<dt><a href=\"#always_quiet_mode\">10. Working with Vaadin Themes<\/a><\/dt>\n<dt><a href=\"#conclusion\">11. Conclusion<\/a><\/dt>\n<dt><a href=\"#download_code\">12. Download the Source Code<\/a><\/dt>\n<\/dl>\n<\/div>\n<h2 id=\"how_vaadin\">2. How Vaadin works?<\/h2>\n<p>Generally speaking, Vaadin is a lot like AWT, Spring and SWT. We have some layouts &amp; components which we instantiate and provide our data to, finally bind them together in a parent layout to show the container. The difference arises on how these components &amp; layouts are actually rendered. Instead of the traditional components being rendered using Java whose layout depends on the underlying Operating system, Vaadin components are the HTML5\/CSS\/JavaScript components talking via Ajax to the backend server and managed automatically by the framework. Let us visualise how Vaadin is arranged between frontend UI engines and its own components:<\/p>\n<p><figure id=\"attachment_76884\" aria-describedby=\"caption-attachment-76884\" style=\"width: 761px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-arch.png\"><img decoding=\"async\" class=\"size-full wp-image-76884\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-arch.png\" alt=\"\" width=\"761\" height=\"621\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-arch.png 761w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-arch-300x245.png 300w\" sizes=\"(max-width: 761px) 100vw, 761px\" \/><\/a><figcaption id=\"caption-attachment-76884\" class=\"wp-caption-text\">Vaadin Architecture<\/figcaption><\/figure><\/p>\n<p>In above figure, it is very much clear how Vaadin guards backend developers against writing HTML, CSS and JS based components and provide a Vaadin engine where we can work on Java code itself for UI components which may be later translated to HTML Components by the framework itself.<\/p>\n<p>It is the client-side Vaadin engine (written in HTML5\/CSS\/JavaScript, and based on the Google Web Toolkit) and the server-side framework which manage the UI for us. Server-side components also support data-binding in Vaadin which makes it very easy to integrate database in the components. Finally, do not think that Vaadin is only limited to Java. With newest versions of Vaadin, it is also possible to write HTML based Vaadin layout, style it with CSS and tune the behaviour with Javascript itself. In this lesson, we will limit ourselves to using the Java language only.<\/p>\n<h2 id=\"plugin\">3. Vaadin Plugins<\/h2>\n<p>Now that we understand how Vaadin works, we are ready to setup our machine for its development. To move on with the lesson and an easy to use plugins available right inside your IDE, we can install Eclipse plugin as:<\/p>\n<p><figure id=\"attachment_76917\" aria-describedby=\"caption-attachment-76917\" style=\"width: 649px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-eclipse-plugin.png\"><img decoding=\"async\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-eclipse-plugin.png\" alt=\"Vaadin Eclipse Plugin\" width=\"649\" height=\"963\" class=\"size-full wp-image-76917\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-eclipse-plugin.png 649w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-eclipse-plugin-202x300.png 202w\" sizes=\"(max-width: 649px) 100vw, 649px\" \/><\/a><figcaption id=\"caption-attachment-76917\" class=\"wp-caption-text\">Vaadin Eclipse Plugin<\/figcaption><\/figure><\/p>\n<p>If you use IntelliJ (like me), we can get the plugin for the IDE as well:<\/p>\n<p><figure id=\"attachment_76890\" aria-describedby=\"caption-attachment-76890\" style=\"width: 820px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-intellij-plugin.png\"><img decoding=\"async\" class=\"size-full wp-image-76890\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-intellij-plugin.png\" alt=\"Vaadin IntelliJ Plugin\" width=\"820\" height=\"656\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-intellij-plugin.png 820w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-intellij-plugin-300x240.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-intellij-plugin-768x614.png 768w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><figcaption id=\"caption-attachment-76890\" class=\"wp-caption-text\">Vaadin IntelliJ Plugin<\/figcaption><\/figure><\/p>\n<p>The plugin is not absolutely needed but it opens an opportunity of working with 100% UI based system where you can work with WYSIWYG systems.<\/p>\n<h2 id=\"setup_project\">4. Creating a Project<\/h2>\n<p>Now that we are ready with everything, we can finally use Maven to create a project for us. We will be using a Vaadin archtype to create an application. Let&#8217;s look at the command in action here:<\/p>\n<p><span style=\"text-decoration: underline\"><em>Creating a Project<\/em><\/span><\/p>\n<pre class=\"brush:bash\">mvn archetype:generate -DarchetypeGroupId=com.vaadin -DarchetypeArtifactId=vaadin-archetype-application -DarchetypeVersion=LATEST -DgroupId=com.javacodegeeks.example -DartifactId=JCG-Vaadin-Example -Dversion=1.0 -Dpackaging=jar\r\n<\/pre>\n<p>Here is what we get when we create the project (we only show the interesting parts):<\/p>\n<p><span style=\"text-decoration: underline\"><em>Creating a project<\/em><\/span><\/p>\n<pre class=\"brush:bash\">[INFO] Scanning for projects...\r\n[INFO]\r\n[INFO] ------------------&lt; org.apache.maven:standalone-pom &gt;-------------------\r\n[INFO] Building Maven Stub Project (No POM) 1\r\n[INFO] --------------------------------[ pom ]---------------------------------\r\n[INFO]\r\n[INFO] &gt;&gt;&gt; maven-archetype-plugin:3.0.1:generate (default-cli) &gt; generate-sources @ standalone-pom &gt;&gt;&gt;\r\n[INFO]\r\n[INFO] &lt;&lt;&lt; maven-archetype-plugin:3.0.1:generate (default-cli) &lt; generate-sources @ standalone-pom &lt;&lt;&lt;\r\n[INFO]\r\n[INFO]\r\n[INFO] --- maven-archetype-plugin:3.0.1:generate (default-cli) @ standalone-pom ---\r\n[INFO] Generating project in Interactive mode\r\n[INFO] Archetype repository not defined. Using the one from [com.vaadin:vaadin-archetype-application:8.4.1] found in catalog remote\r\n\r\n....some non-interesting parts....\r\n\r\n[INFO] Using property: groupId = com.javacodegeeks.example\r\n[INFO] Using property: artifactId = JCG-Vaadin-Example\r\n[INFO] Using property: version = 1.0\r\n[INFO] Using property: package = com.javacodegeeks.example\r\n[INFO] Using property: themeName = mytheme\r\n[INFO] Using property: uiName = MyUI\r\nConfirm properties configuration:\r\ngroupId: com.javacodegeeks.example\r\nartifactId: JCG-Vaadin-Example\r\nversion: 1.0\r\npackage: com.javacodegeeks.example\r\nthemeName: mytheme\r\nuiName: MyUI\r\n Y: :\r\n[INFO] ----------------------------------------------------------------------------\r\n[INFO] Using following parameters for creating project from Archetype: vaadin-archetype-application:LATEST\r\n[INFO] ----------------------------------------------------------------------------\r\n[INFO] Parameter: groupId, Value: com.javacodegeeks.example\r\n[INFO] Parameter: artifactId, Value: JCG-Vaadin-Example\r\n[INFO] Parameter: version, Value: 1.0\r\n[INFO] Parameter: package, Value: com.javacodegeeks.example\r\n[INFO] Parameter: packageInPathFormat, Value: com\/javacodegeeks\/example\r\n[INFO] Parameter: package, Value: com.javacodegeeks.example\r\n[INFO] Parameter: version, Value: 1.0\r\n[INFO] Parameter: groupId, Value: com.javacodegeeks.example\r\n[INFO] Parameter: themeName, Value: mytheme\r\n[INFO] Parameter: uiName, Value: MyUI\r\n[INFO] Parameter: artifactId, Value: JCG-Vaadin-Example\r\n[INFO] Project created from Archetype in dir: \/Users\/shubham\/JCG-Vaadin-Example\r\n[INFO] ------------------------------------------------------------------------\r\n[INFO] BUILD SUCCESS\r\n[INFO] ------------------------------------------------------------------------\r\n[INFO] Total time: 32.100 s\r\n[INFO] Finished at: 2018-05-13T18:43:43+05:30\r\n[INFO] ------------------------------------------------------------------------\r\n<\/pre>\n<p>Vaadin archtype takes care of adding appropriate dependencies in our project along with all other information needed to build the project. In the next section, we will understand all parts which were in the <code>pom.xml<\/code> file of the project.<\/p>\n<h2 id=\"maven_dependency\">5. Maven Dependencies<\/h2>\n<p>The project we built using the Vaadin archtype takes care of adding appropriate dependencies in our project. Let us take a peek at the <code>pom.xml<\/code> file of the project in parts. Let&#8217;s start by looking at the dependencies which were added to the file:<\/p>\n<p><span style=\"text-decoration: underline\"><em>pom.xml<\/em><\/span><\/p>\n<pre class=\"brush:xml\">&lt;dependencies&gt;\r\n    &lt;dependency&gt;\r\n        &lt;groupId&gt;javax.servlet&lt;\/groupId&gt;\r\n        &lt;artifactId&gt;javax.servlet-api&lt;\/artifactId&gt;\r\n        &lt;version&gt;3.0.1&lt;\/version&gt;\r\n        &lt;scope&gt;provided&lt;\/scope&gt;\r\n    &lt;\/dependency&gt;\r\n    &lt;dependency&gt;\r\n        &lt;groupId&gt;com.vaadin&lt;\/groupId&gt;\r\n        &lt;artifactId&gt;vaadin-server&lt;\/artifactId&gt;\r\n    &lt;\/dependency&gt;\r\n    &lt;dependency&gt;\r\n        &lt;groupId&gt;com.vaadin&lt;\/groupId&gt;\r\n        &lt;artifactId&gt;vaadin-push&lt;\/artifactId&gt;\r\n    &lt;\/dependency&gt;\r\n    &lt;dependency&gt;\r\n        &lt;groupId&gt;com.vaadin&lt;\/groupId&gt;\r\n        &lt;artifactId&gt;vaadin-client-compiled&lt;\/artifactId&gt;\r\n    &lt;\/dependency&gt;\r\n    &lt;dependency&gt;\r\n        &lt;groupId&gt;com.vaadin&lt;\/groupId&gt;\r\n        &lt;artifactId&gt;vaadin-themes&lt;\/artifactId&gt;\r\n    &lt;\/dependency&gt;\r\n&lt;\/dependencies&gt;\r\n<\/pre>\n<p>Following dependencies were added to the project:<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<ul>\n<li><code>javax.servlet-api<\/code>: This dependency provides the ability to keep Servlets in our project to make network calls<\/li>\n<li><code>vaadin-server<\/code>: This dependency includes packages for managing the server details like sessions, client communication etc.<\/li>\n<li><code>vaadin-push<\/code>: This dependency is not necessary for this lesson but is still important to show. When we need to update the UI based on a thread executing on the server, we can send a request from the server to UI so that UI is immediately updated and UI doesn&#8217;t have to make a network request to get the data state on the server. For this, push packages are used.<\/li>\n<li><code>vaadin-client-compiled<\/code>: This dependency is based on GWT and contains packages to compile the client components.<\/li>\n<li><code>vaadin-themes<\/code>: This dependency includes some built-in themes and all utilities for making custom themes.<\/li>\n<\/ul>\n<p>Next, we also need to add the Vaadin repository and the dependency management. The <code>dependencyManagement<\/code> tag helps to manage the version of all Vaadin dependencies:<\/p>\n<p><span style=\"text-decoration: underline\"><em>pom.xml<\/em><\/span><\/p>\n<pre class=\"brush:xml\">&lt;repositories&gt;\r\n    &lt;repository&gt;\r\n        &lt;id&gt;vaadin-addons&lt;\/id&gt;\r\n        &lt;url&gt;http:\/\/maven.vaadin.com\/vaadin-addons&lt;\/url&gt;\r\n    &lt;\/repository&gt;\r\n&lt;\/repositories&gt;\r\n\r\n&lt;dependencyManagement&gt;\r\n    &lt;dependencies&gt;\r\n        &lt;dependency&gt;\r\n            &lt;groupId&gt;com.vaadin&lt;\/groupId&gt;\r\n            &lt;artifactId&gt;vaadin-bom&lt;\/artifactId&gt;\r\n            &lt;version&gt;${vaadin.version}&lt;\/version&gt;\r\n            &lt;type&gt;pom&lt;\/type&gt;\r\n            &lt;scope&gt;import&lt;\/scope&gt;\r\n        &lt;\/dependency&gt;\r\n    &lt;\/dependencies&gt;\r\n&lt;\/dependencyManagement&gt;\r\n<\/pre>\n<p>Finally, we need to have the Jetty plugin which allows us to easily test the development build by running <code>jetty:run<\/code> on the command line.<\/p>\n<p><span style=\"text-decoration: underline\"><em>pom.xml<\/em><\/span><\/p>\n<pre class=\"brush:xml\">&lt;plugin&gt;\r\n    &lt;groupId&gt;org.eclipse.jetty&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;jetty-maven-plugin&lt;\/artifactId&gt;\r\n    &lt;version&gt;${jetty.plugin.version}&lt;\/version&gt;\r\n    &lt;configuration&gt;\r\n        &lt;scanIntervalSeconds&gt;2&lt;\/scanIntervalSeconds&gt;\r\n    &lt;\/configuration&gt;\r\n&lt;\/plugin&gt;\r\n<\/pre>\n<p>This allows us to run the Vaadin app directly from the command-line and provides us with an embedded Jetty server.<\/p>\n<h2 id=\"vaadin_servlet\">6. Vaadin Servlet<\/h2>\n<p>In Vaadin, we don&#8217;t have a web.xml file to configure the dispatcher servlet for the application. Instead, we have the Vaadin Servlet, which with the help of some annotations defines the entry point of the application:<\/p>\n<p><span style=\"text-decoration: underline\"><em>MyUI.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">@WebServlet(urlPatterns = \"\/*\", name = \"MyUIServlet\", asyncSupported = true)\r\n@VaadinServletConfiguration(ui = MyUI.class, productionMode = false)\r\npublic static class MyUIServlet extends VaadinServlet { }\r\n<\/pre>\n<p>In above servlet application, the <code>ui<\/code> field clearly mentions that <code>MyUI.class<\/code> is the main entry point for the specified application.<\/p>\n<h2 id=\"main_class\">7. Vaadin Main Class<\/h2>\n<p>As we have defined our application using the Vaadin archtype, the app comes with a basic UI already set up in the main class of the application, which as shown in the previous section, also contains the definition for the Vaadin Servlet. Here is the main entry point UI class pre-defined in our application:<\/p>\n<p><span style=\"text-decoration: underline\"><em>MyUI.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.example;\r\n\r\nimport javax.servlet.annotation.WebServlet;\r\n\r\nimport com.vaadin.annotations.Theme;\r\nimport com.vaadin.annotations.VaadinServletConfiguration;\r\nimport com.vaadin.server.VaadinRequest;\r\nimport com.vaadin.server.VaadinServlet;\r\nimport com.vaadin.ui.Button;\r\nimport com.vaadin.ui.Label;\r\nimport com.vaadin.ui.TextField;\r\nimport com.vaadin.ui.UI;\r\nimport com.vaadin.ui.VerticalLayout;\r\n\r\n@Theme(\"mytheme\")\r\npublic class MyUI extends UI {\r\n\r\n    private static final long serialVersionUID = 7132834690301152714L;\r\n\r\n    @Override\r\n    protected void init(VaadinRequest vaadinRequest) {\r\n        final VerticalLayout layout = new VerticalLayout();\r\n        \r\n        final TextField name = new TextField();\r\n        name.setCaption(\"Type your name here:\");\r\n\r\n        Button button = new Button(\"Click Me\");\r\n        button.addClickListener(e -&gt; {\r\n            layout.addComponent(new Label(\"Thanks \" + name.getValue() \r\n                    + \", it works!\"));\r\n        });\r\n        \r\n        layout.addComponents(name, button);\r\n        \r\n        setContent(layout);\r\n    }\r\n\r\n    @WebServlet(urlPatterns = \"\/*\", name = \"MyUIServlet\", asyncSupported = true)\r\n    @VaadinServletConfiguration(ui = MyUI.class, productionMode = false)\r\n    public static class MyUIServlet extends VaadinServlet {\r\n    }\r\n}\r\n<\/pre>\n<p>This UI is the application entry point. A UI may either represent a browser window (or tab) or some part of an HTML page where a Vaadin application is embedded. The UI is initialized using <a href=\"https:\/\/vaadin.com\/api\/com\/vaadin\/server\/VaadinRequest.html\" target=\"_blank\" rel=\"noopener\">VaadinRequest<\/a>. This method is intended to be overridden to add component to the user interface and initialize non-component functionality.<\/p>\n<p>Actually, we&#8217;re ready to run the project as of now to show the default application layout made by the Vaadin archtype itself. Run the following command to run the project:<\/p>\n<p><span style=\"text-decoration: underline\"><em>Running the project<\/em><\/span><\/p>\n<pre class=\"brush:bash\">mvn jetty:run\r\n<\/pre>\n<p>Visit the following URL to see the app running:<\/p>\n<p><span style=\"text-decoration: underline\"><em>URL to open<\/em><\/span><\/p>\n<pre class=\"brush:bash\">http:\/\/localhost:8080\/\r\n<\/pre>\n<p>We can try the app now:<\/p>\n<p><figure id=\"attachment_76895\" aria-describedby=\"caption-attachment-76895\" style=\"width: 554px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-run-sample-app.png\"><img decoding=\"async\" class=\"size-full wp-image-76895\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-run-sample-app.png\" alt=\"Running Sample Application\" width=\"554\" height=\"337\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-run-sample-app.png 554w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-run-sample-app-300x182.png 300w\" sizes=\"(max-width: 554px) 100vw, 554px\" \/><\/a><figcaption id=\"caption-attachment-76895\" class=\"wp-caption-text\">Running Sample Application<\/figcaption><\/figure><\/p>\n<h2 id=\"layout_mgr\">8. Vaadin Layout Managers<\/h2>\n<p>The sample application we ran above made use of a <code>VerticalLayout<\/code> to arrange the UI elements in a vertical manner. Similar to the <code>VerticalLayout<\/code>, Vaadin provides us various Layout Managers to arrange the UI components in different directions. Let&#8217;s explore what the managers are<\/p>\n<h3 id=\"vertical_layout\">8.1 VerticalLayout<\/h3>\n<p>When we need to stack the components in a single column where first elements are kept on the bottom and the rest of the elements appear below the above component, we can use the <code>VerticalLayout<\/code> arrangement:<\/p>\n<p><span style=\"text-decoration: underline\"><em>VerticalLayout<\/em><\/span><\/p>\n<pre class=\"brush:java\">VerticalLayout vertical = new VerticalLayout();\r\nvertical.setSpacing(true);\r\nvertical.setMargin(true);\r\nsetContent(vertical);\r\n<\/pre>\n<p>All the components added to this layout will be stacked on top of each other. Note that the methods related to each component (<strong>a layout is a component as well<\/strong>) are well-styled with names based on the CSS property they set. This makes the method names easy to guess and much more readable.<\/p>\n<h3 id=\"horizontal_layout\">8.2 HorizontalLayout<\/h3>\n<p>As against the <code>VerticalLayout<\/code> where components are arranged in a vertical manner, <code>HorizontalLayout<\/code> arranges the components horizontally. Let&#8217;s look at an example of how this layout can be instantiated:<\/p>\n<p><span style=\"text-decoration: underline\"><em>HorizontalLayout<\/em><\/span><\/p>\n<pre class=\"brush:java\">final HorizontalLayout layout = new HorizontalLayout();\r\n<\/pre>\n<p>In the sample application, just replace the <code>VerticalLayout<\/code> with the <code>VerticalLayout<\/code> and see how the layout appears now:<\/p>\n<p><figure id=\"attachment_76898\" aria-describedby=\"caption-attachment-76898\" style=\"width: 626px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-horizontal-layout.png\"><img decoding=\"async\" class=\"size-full wp-image-76898\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-horizontal-layout.png\" alt=\"Vaadin Horizontal layout\" width=\"626\" height=\"272\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-horizontal-layout.png 626w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-horizontal-layout-300x130.png 300w\" sizes=\"(max-width: 626px) 100vw, 626px\" \/><\/a><figcaption id=\"caption-attachment-76898\" class=\"wp-caption-text\">Vaadin Horizontal layout<\/figcaption><\/figure><\/p>\n<h3 id=\"grid_layout\">8.3 GridLayout<\/h3>\n<p>Another layout, <code>GridLayout<\/code> allows us to make a Grid of components which provides a very sleek and consistent look to the page we render.<\/p>\n<p><span style=\"text-decoration: underline\"><em>GridLayout<\/em><\/span><\/p>\n<pre class=\"brush:java\">GridLayout gridLayout = new GridLayout(3, 2);\r\n<\/pre>\n<p>Go on and try the <code>GridLayout<\/code> in the existing layout to play with the arrangement of the UI components.<\/p>\n<h3 id=\"form_layout\">8.4 FormLayout<\/h3>\n<p>Finally, we can use the <code>FormLayout<\/code> which puts the label of a component and the component itself in two separate columns and can also have the optional indicator for required fields. It can be instantiated as:<\/p>\n<p><span style=\"text-decoration: underline\"><em>FormLayout<\/em><\/span><\/p>\n<pre class=\"brush:java\">FormLayout formLayout = new FormLayout();\r\n<\/pre>\n<h2>9. Vaadin Components<\/h2>\n<p>In this section, we will look at some basic but most useful Vaadin UI elements which are used in almost all of the UIs made for Web.<\/p>\n<h3 id=\"label\">9.1 Label<\/h3>\n<p>A <code>Label<\/code> is a component which is used to show a static text which doesn&#8217;t modify with application state. Let&#8217;s define a function which provides a <code>Label<\/code> instance and sets it in a <code>VerticalLayout<\/code>:<\/p>\n<p><span style=\"text-decoration: underline\"><em>Label<\/em><\/span><\/p>\n<pre class=\"brush:java\">private Layout showLabels() {\r\n    final VerticalLayout layout = new VerticalLayout();\r\n\r\n    Label label = new Label();\r\n    label.setId(\"LabelID\");\r\n    label.setValue(\"JavaCodeGeeks\");\r\n    label.setCaption(\"Label\");\r\n    layout.addComponent(label);\r\n    return layout;\r\n}\r\n<\/pre>\n<p>Here is how this <code>Label<\/code> looks:<br \/>\n<figure id=\"attachment_76900\" aria-describedby=\"caption-attachment-76900\" style=\"width: 626px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-label.png\"><img decoding=\"async\" class=\"size-full wp-image-76900\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-label.png\" alt=\"Label in Vaadin\" width=\"626\" height=\"295\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-label.png 626w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-label-300x141.png 300w\" sizes=\"(max-width: 626px) 100vw, 626px\" \/><\/a><figcaption id=\"caption-attachment-76900\" class=\"wp-caption-text\">Label in Vaadin<\/figcaption><\/figure><\/p>\n<h3 id=\"link\">9.2 Link<\/h3>\n<p>When it comes to providing an address to external web pages, Vaadin provides the Link component which serves the same purpose:<\/p>\n<p><span style=\"text-decoration: underline\"><em>Link<\/em><\/span><\/p>\n<pre class=\"brush:java\">private Layout showLink() {\r\n    final VerticalLayout layout = new VerticalLayout();\r\n\r\n    Link jcgLink = new Link(\"JavaCodeGeeks\",\r\n            new ExternalResource(\"https:\/\/www.javacodegeeks.com\/\"));\r\n    jcgLink.setTargetName(\"_blank\");\r\n    layout.addComponent(jcgLink);\r\n    return layout;\r\n}\r\n<\/pre>\n<p>Here is how a <code>Link<\/code> looks:<\/p>\n<p><figure id=\"attachment_76902\" aria-describedby=\"caption-attachment-76902\" style=\"width: 626px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-link-component.png\"><img decoding=\"async\" class=\"size-full wp-image-76902\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-link-component.png\" alt=\"Vaadin Link component\" width=\"626\" height=\"295\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-link-component.png 626w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-link-component-300x141.png 300w\" sizes=\"(max-width: 626px) 100vw, 626px\" \/><\/a><figcaption id=\"caption-attachment-76902\" class=\"wp-caption-text\">Vaadin Link component<\/figcaption><\/figure><\/p>\n<h3 id=\"textfield\">9.3 TextField<\/h3>\n<p><code>TextFields<\/code> are the components which are a combination of a <code>Label<\/code> component and a single line <code>TextArea<\/code> which allows a user to provide an input. Here is a sample program to show a\u00a0<code>TextField<\/code> with an icon as well which inbuilt into the Vaadin libraries:<\/p>\n<p><span style=\"text-decoration: underline\"><em>TextField<\/em><\/span><\/p>\n<pre class=\"brush:java\">private Layout showTextField() {\r\n    final VerticalLayout layout = new VerticalLayout();\r\n\r\n    TextField textField = new TextField();\r\n    textField.setIcon(FontAwesome.USER);\r\n    layout.addComponent(textField);\r\n    return layout;\r\n}\r\n<\/pre>\n<p>Here is how a <code>TextField<\/code> looks:<br \/>\n<figure id=\"attachment_76903\" aria-describedby=\"caption-attachment-76903\" style=\"width: 626px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-textfield-component.png\"><img decoding=\"async\" class=\"size-full wp-image-76903\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-textfield-component.png\" alt=\"Vaadin TextField component\" width=\"626\" height=\"295\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-textfield-component.png 626w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-textfield-component-300x141.png 300w\" sizes=\"(max-width: 626px) 100vw, 626px\" \/><\/a><figcaption id=\"caption-attachment-76903\" class=\"wp-caption-text\">Vaadin TextField component<\/figcaption><\/figure><\/p>\n<h3 id=\"text_area\">9.4 TextArea<\/h3>\n<p>A\u00a0<code>TextArea<\/code> component is just like a\u00a0<code>TextField<\/code>\u00a0component with an only difference is that multiple lines of input are allowed in a <code>TextArea<\/code> component. Let us take a look at a demonstration:<\/p>\n<p><span style=\"text-decoration: underline\"><em>TextArea<\/em><\/span><\/p>\n<pre class=\"brush:java\">private Layout showTextArea() {\r\n    final VerticalLayout layout = new VerticalLayout();\r\n\r\n    TextArea textArea = new TextArea();\r\n    layout.addComponent(textArea);\r\n    return layout;\r\n}\r\n<\/pre>\n<p>Here is how a <code>TextArea<\/code> looks:<\/p>\n<p><figure id=\"attachment_76904\" aria-describedby=\"caption-attachment-76904\" style=\"width: 626px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-textarea-component.png\"><img decoding=\"async\" class=\"size-full wp-image-76904\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-textarea-component.png\" alt=\"Vaadin TextArea component\" width=\"626\" height=\"295\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-textarea-component.png 626w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-textarea-component-300x141.png 300w\" sizes=\"(max-width: 626px) 100vw, 626px\" \/><\/a><figcaption id=\"caption-attachment-76904\" class=\"wp-caption-text\">Vaadin TextArea component<\/figcaption><\/figure><br \/>\nThe <code>TextArea<\/code> component allows us to enter big text into the components and reflect limit of text that should be entered as well.<\/p>\n<h3 id=\"date_field\">9.5 DateField and InlineDateField<\/h3>\n<p>Picking dates is a very common task in a Web UI. Vaadin provides us two elements to do the same, <code>DateField<\/code> and <code>InlineDateField<\/code>. A <code>DateField<\/code> component shows a dropdown calendar where we can pick a date. <code>InLineDateField<\/code> doesn&#8217;t disappear when we have selected a date in it. Let us take a look at a sample program:<\/p>\n<p><span style=\"text-decoration: underline\"><em>DateField and InlineDateField<\/em><\/span><\/p>\n<pre class=\"brush:java\">private Layout showDateField() {\r\n    final VerticalLayout layout = new VerticalLayout();\r\n\r\n    DateField dateField = new DateField(\"DateField\", LocalDate.now());\r\n    InlineDateField inlineDateField = new InlineDateField();\r\n    layout.addComponent(dateField);\r\n    layout.addComponent(inlineDateField);\r\n    return layout;\r\n}\r\n<\/pre>\n<p>Here is how a <code>DateField<\/code> looks:<br \/>\n<figure id=\"attachment_76905\" aria-describedby=\"caption-attachment-76905\" style=\"width: 666px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-datefield-component.png\"><img decoding=\"async\" class=\"size-full wp-image-76905\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-datefield-component.png\" alt=\"Vaadin DateField component\" width=\"666\" height=\"579\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-datefield-component.png 666w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-datefield-component-300x261.png 300w\" sizes=\"(max-width: 666px) 100vw, 666px\" \/><\/a><figcaption id=\"caption-attachment-76905\" class=\"wp-caption-text\">Vaadin DateField component<\/figcaption><\/figure><\/p>\n<p>Here is how a <code>InLineDateField<\/code> looks:<br \/>\n<figure id=\"attachment_76906\" aria-describedby=\"caption-attachment-76906\" style=\"width: 666px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-inlinedatefield-component.png\"><img decoding=\"async\" class=\"size-full wp-image-76906\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-inlinedatefield-component.png\" alt=\"Vaadin InLine DateField component\" width=\"666\" height=\"579\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-inlinedatefield-component.png 666w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-inlinedatefield-component-300x261.png 300w\" sizes=\"(max-width: 666px) 100vw, 666px\" \/><\/a><figcaption id=\"caption-attachment-76906\" class=\"wp-caption-text\">Vaadin InLine DateField component<\/figcaption><\/figure><br \/>\nThe <code>InlineDateField<\/code> doesn&#8217;t disappear when user has done selecting a date from it.<\/p>\n<h3 id=\"pwd_field\">9.6 PasswordField<\/h3>\n<p>To accept secret keys and passwords in the UI, we can make use of the <code>PasswordField<\/code>.\u00a0Let us take a look at a demonstration:<\/p>\n<p><span style=\"text-decoration: underline\"><em>PasswordField<\/em><\/span><\/p>\n<pre class=\"brush:java\">private Layout showPasswordField() {\r\n    final VerticalLayout layout = new VerticalLayout();\r\n\r\n    PasswordField passwordField = new PasswordField();\r\n    layout.addComponent(passwordField);\r\n    return layout;\r\n}\r\n<\/pre>\n<p>Here is how a <code>PasswordField<\/code> looks:<\/p>\n<p><figure id=\"attachment_76907\" aria-describedby=\"caption-attachment-76907\" style=\"width: 586px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-pwdfield-component.png\"><img decoding=\"async\" class=\"size-full wp-image-76907\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-pwdfield-component.png\" alt=\"Vaadin PasswordField component\" width=\"586\" height=\"272\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-pwdfield-component.png 586w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-pwdfield-component-300x139.png 300w\" sizes=\"(max-width: 586px) 100vw, 586px\" \/><\/a><figcaption id=\"caption-attachment-76907\" class=\"wp-caption-text\">Vaadin PasswordField component<\/figcaption><\/figure><br \/>\nA <code>PasswordField<\/code> is a <code>TextField<\/code> which just masks the text we enter into it.<\/p>\n<h3 id=\"button\">9.7 Button<\/h3>\n<p>To provide a user with an ability to perform an action in certain cases like to submit a form or similar, Button is the best component to make use of.\u00a0Let us take a look at a sample program:<\/p>\n<p><span style=\"text-decoration: underline\"><em>Button<\/em><\/span><\/p>\n<pre class=\"brush:java\">private Layout showButton() {\r\n    final VerticalLayout layout = new VerticalLayout();\r\n\r\n    Button normalButton = new Button(\"Normal Button\");\r\n    layout.addComponent(normalButton);\r\n    return layout;\r\n}\r\n<\/pre>\n<p>Here is how a <code>Button<\/code> component looks like:<\/p>\n<p><figure id=\"attachment_76908\" aria-describedby=\"caption-attachment-76908\" style=\"width: 556px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-button-component.png\"><img decoding=\"async\" class=\"size-full wp-image-76908\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-button-component.png\" alt=\"Vaadin Button component\" width=\"556\" height=\"272\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-button-component.png 556w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-button-component-300x147.png 300w\" sizes=\"(max-width: 556px) 100vw, 556px\" \/><\/a><figcaption id=\"caption-attachment-76908\" class=\"wp-caption-text\">Vaadin Button component<\/figcaption><\/figure><br \/>\nVaadin allows us to make many type of buttons like Danger buttons (red in colour by default), quite buttons and many more.<\/p>\n<h3 id=\"check_box\">9.8 CheckBox<\/h3>\n<p>To accept multiple values to some value, we can make of <code>CheckBoxes<\/code> which allows a user to set or unset them without being dependent if other <code>CheckBoxes <\/code>in the UI are set or not.\u00a0Let us take a look at a sample program:<\/p>\n<p><span style=\"text-decoration: underline\"><em>CheckBox<\/em><\/span><\/p>\n<pre class=\"brush:java\">private Layout showCheckBox() {\r\n    final VerticalLayout layout = new VerticalLayout();\r\n\r\n    CheckBox checkbox = new CheckBox(\"CheckBox\");\r\n    checkbox.setValue(true);\r\n    layout.addComponent(checkbox);\r\n    return layout;\r\n}\r\n<\/pre>\n<p>Here is how a <code>CheckBox<\/code> component looks:<br \/>\n<figure id=\"attachment_76909\" aria-describedby=\"caption-attachment-76909\" style=\"width: 556px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-checkbox-component.png\"><img decoding=\"async\" class=\"size-full wp-image-76909\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-checkbox-component.png\" alt=\"Vaadin checkbox component\" width=\"556\" height=\"272\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-checkbox-component.png 556w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-checkbox-component-300x147.png 300w\" sizes=\"(max-width: 556px) 100vw, 556px\" \/><\/a><figcaption id=\"caption-attachment-76909\" class=\"wp-caption-text\">Vaadin checkbox component<\/figcaption><\/figure><\/p>\n<h3 id=\"lists\">9.9 Lists<\/h3>\n<p>As a final component, showing a list of items which contains a fixed element is a very common task. Let us take a look at a demonstration on how we can do this:<\/p>\n<p><span style=\"text-decoration: underline\"><em>Lists<\/em><\/span><\/p>\n<pre class=\"brush:java\">private Layout showLists() {\r\n    final VerticalLayout layout = new VerticalLayout();\r\n\r\n    List&lt;String&gt; numbers = new ArrayList&lt;&gt;();\r\n    numbers.add(\"One\");\r\n    numbers.add(\"Ten\");\r\n    numbers.add(\"Eleven\");\r\n\r\n    ComboBox comboBox = new ComboBox(\"ComboBox\");\r\n    comboBox.setItems(numbers);\r\n\r\n    layout.addComponent(comboBox);\r\n    return layout;\r\n}\r\n<\/pre>\n<p>Here is how a <code>Lists<\/code> component looks:<\/p>\n<p><figure id=\"attachment_76910\" aria-describedby=\"caption-attachment-76910\" style=\"width: 594px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-lists-component.png\"><img decoding=\"async\" class=\"size-full wp-image-76910\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-lists-component.png\" alt=\"Vaadin lists component\" width=\"594\" height=\"352\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-lists-component.png 594w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/vaadin-lists-component-300x178.png 300w\" sizes=\"(max-width: 594px) 100vw, 594px\" \/><\/a><figcaption id=\"caption-attachment-76910\" class=\"wp-caption-text\">Vaadin lists component<\/figcaption><\/figure><\/p>\n<p>So, we just made a List to collect items into it and show those items into the <code>ComboBox<\/code> element which shows a drop-down menu containing the List items.<\/p>\n<h2 id=\"vaadin_themes\">10. Working with Vaadin Themes<\/h2>\n<p>Vaadin themes are the best way to completely transform an application look by just pointing it towards a new theme altogether in the stylesheets Vaadin project uses. By default, Vaadin provides\u00a0four built-in themes we can readily change among.\u00a0The built-in themes are\u00a0<em>valo<\/em>,\u00a0<em>reindeer<\/em>,\u00a0<em>chameleon<\/em>, and\u00a0<em>runo<\/em>. To find the stylesheet, visit the\u00a0<code>WebContent\/themes\/declarativeui\/declarativeui.scss<\/code>. We can change the theme value specified toward the end of the specified file will change the theme the application picks.<\/p>\n<p>Do take a look at the <a href=\"https:\/\/vaadin.com\/directory#!browse\" rel=\"noopener\" target=\"_blank\">Vaadin directory<\/a> to find almost unlimitd number of ready to use Vaadin themes which can be used in your projects.<\/p>\n<h2 id=\"conclusion\">11. Conclusion<\/h2>\n<p>In this lesson, we studied how we can make a very simple but effective Vaadin application with a single Maven command. We saw what Maven dependencies and plugins are needed for a production-grade Vaadin application. We looked at many Vaadin components which are commonly used in Vaadin UI applications. For a Java Backend engineer, Vaadin is an excellent Framework. It provides every advantage that a Java developer can think of, as it allows Maven-based build system for dependency management, a very easy way to directly use Spring services in the same project itself or just follow a Design Pattern to keep the UI and network layer completely separate in a project.<\/p>\n<p>In one of the future Vaadin lessons, we will see how we can make a Vaadin application dynamic by adding a working backend to our application like using a <a href=\"https:\/\/www.javacodegeeks.com\/2018\/04\/spring-boot-tutorial.html\" rel=\"noopener\" target=\"_blank\">Spring Boot<\/a> application to provide dynamic content from the database to the application.<\/p>\n<h2 id=\"download_code\">12. Download the Source Code<\/h2>\n<p>This was an example of Vaadin Framework.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <strong><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/05\/JCG-Vaadin-Example.zip\" rel=\"noopener\" target=\"_blank\">Vaadin Example<\/a><\/strong><\/div>\n","protected":false},"excerpt":{"rendered":"<p>1. Introduction When you are a backend developer, you know the pain which is caused when you hear people saying you can&#8217;t create UI pages built-in HTML and can&#8217;t style them in CSS. It&#8217;s like being a backend developer has its known limitations that we can play and run big production backend applications but can&#8217;t &hellip;<\/p>\n","protected":false},"author":20016,"featured_media":249,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[294],"class_list":["post-76881","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-vaadin"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Vaadin Tutorial - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"1. Introduction When you are a backend developer, you know the pain which is caused when you hear people saying you can&#039;t create UI pages built-in HTML\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2018\/05\/vaadin-tutorial.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Vaadin Tutorial - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"1. Introduction When you are a backend developer, you know the pain which is caused when you hear people saying you can&#039;t create UI pages built-in HTML\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2018\/05\/vaadin-tutorial.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2018-05-15T07:00:39+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/vaadin-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Shubham Aggarwal\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Shubham Aggarwal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"17 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/05\\\/vaadin-tutorial.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/05\\\/vaadin-tutorial.html\"},\"author\":{\"name\":\"Shubham Aggarwal\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/0953481a8babbb7a63907edb41f357ad\"},\"headline\":\"Vaadin Tutorial\",\"datePublished\":\"2018-05-15T07:00:39+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/05\\\/vaadin-tutorial.html\"},\"wordCount\":2357,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/05\\\/vaadin-tutorial.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/vaadin-logo.jpg\",\"keywords\":[\"Vaadin\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/05\\\/vaadin-tutorial.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/05\\\/vaadin-tutorial.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/05\\\/vaadin-tutorial.html\",\"name\":\"Vaadin Tutorial - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/05\\\/vaadin-tutorial.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/05\\\/vaadin-tutorial.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/vaadin-logo.jpg\",\"datePublished\":\"2018-05-15T07:00:39+00:00\",\"description\":\"1. Introduction When you are a backend developer, you know the pain which is caused when you hear people saying you can't create UI pages built-in HTML\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/05\\\/vaadin-tutorial.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/05\\\/vaadin-tutorial.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/05\\\/vaadin-tutorial.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/vaadin-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/vaadin-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/05\\\/vaadin-tutorial.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Vaadin Tutorial\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/0953481a8babbb7a63907edb41f357ad\",\"name\":\"Shubham Aggarwal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3f2c210fd210e1cafb930887d5f4c29613eb8183e62743a99e0cb93dcaec1a2b?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3f2c210fd210e1cafb930887d5f4c29613eb8183e62743a99e0cb93dcaec1a2b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3f2c210fd210e1cafb930887d5f4c29613eb8183e62743a99e0cb93dcaec1a2b?s=96&d=mm&r=g\",\"caption\":\"Shubham Aggarwal\"},\"description\":\"Shubham is a Java EE Engineer with about 3 years of experience in building quality products with Spring Boot, Spring Data, AWS, Kafka, PrestoDB.\",\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/sbmaggarwal\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/shubham-aggarwal\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Vaadin Tutorial - Java Code Geeks","description":"1. Introduction When you are a backend developer, you know the pain which is caused when you hear people saying you can't create UI pages built-in HTML","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2018\/05\/vaadin-tutorial.html","og_locale":"en_US","og_type":"article","og_title":"Vaadin Tutorial - Java Code Geeks","og_description":"1. Introduction When you are a backend developer, you know the pain which is caused when you hear people saying you can't create UI pages built-in HTML","og_url":"https:\/\/www.javacodegeeks.com\/2018\/05\/vaadin-tutorial.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2018-05-15T07:00:39+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/vaadin-logo.jpg","type":"image\/jpeg"}],"author":"Shubham Aggarwal","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Shubham Aggarwal","Est. reading time":"17 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2018\/05\/vaadin-tutorial.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2018\/05\/vaadin-tutorial.html"},"author":{"name":"Shubham Aggarwal","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/0953481a8babbb7a63907edb41f357ad"},"headline":"Vaadin Tutorial","datePublished":"2018-05-15T07:00:39+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2018\/05\/vaadin-tutorial.html"},"wordCount":2357,"commentCount":3,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2018\/05\/vaadin-tutorial.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/vaadin-logo.jpg","keywords":["Vaadin"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2018\/05\/vaadin-tutorial.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2018\/05\/vaadin-tutorial.html","url":"https:\/\/www.javacodegeeks.com\/2018\/05\/vaadin-tutorial.html","name":"Vaadin Tutorial - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2018\/05\/vaadin-tutorial.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2018\/05\/vaadin-tutorial.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/vaadin-logo.jpg","datePublished":"2018-05-15T07:00:39+00:00","description":"1. Introduction When you are a backend developer, you know the pain which is caused when you hear people saying you can't create UI pages built-in HTML","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2018\/05\/vaadin-tutorial.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2018\/05\/vaadin-tutorial.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2018\/05\/vaadin-tutorial.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/vaadin-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/vaadin-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2018\/05\/vaadin-tutorial.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Vaadin Tutorial"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/0953481a8babbb7a63907edb41f357ad","name":"Shubham Aggarwal","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/3f2c210fd210e1cafb930887d5f4c29613eb8183e62743a99e0cb93dcaec1a2b?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/3f2c210fd210e1cafb930887d5f4c29613eb8183e62743a99e0cb93dcaec1a2b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3f2c210fd210e1cafb930887d5f4c29613eb8183e62743a99e0cb93dcaec1a2b?s=96&d=mm&r=g","caption":"Shubham Aggarwal"},"description":"Shubham is a Java EE Engineer with about 3 years of experience in building quality products with Spring Boot, Spring Data, AWS, Kafka, PrestoDB.","sameAs":["https:\/\/www.linkedin.com\/in\/sbmaggarwal\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/shubham-aggarwal"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/76881","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/20016"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=76881"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/76881\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/249"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=76881"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=76881"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=76881"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}