diff options
author | Erik Lumme <erik@vaadin.com> | 2017-09-14 13:51:12 +0300 |
---|---|---|
committer | Erik Lumme <erik@vaadin.com> | 2017-09-14 13:51:12 +0300 |
commit | 5754df6e95136aee1812491fa069020c12560268 (patch) | |
tree | ed0d0f0aedf5bfa56e20babe0bb6e17ff696ca5b | |
parent | 5da6f980c0585d7f3df3c65eb8a4eee88ce344b7 (diff) | |
download | vaadin-framework-5754df6e95136aee1812491fa069020c12560268.tar.gz vaadin-framework-5754df6e95136aee1812491fa069020c12560268.zip |
Migrate CreatingABasicApplication
-rw-r--r-- | documentation/articles/CreatingABasicApplication.asciidoc | 74 | ||||
-rw-r--r-- | documentation/articles/contents.asciidoc | 1 |
2 files changed, 75 insertions, 0 deletions
diff --git a/documentation/articles/CreatingABasicApplication.asciidoc b/documentation/articles/CreatingABasicApplication.asciidoc new file mode 100644 index 0000000000..e5dde4995f --- /dev/null +++ b/documentation/articles/CreatingABasicApplication.asciidoc @@ -0,0 +1,74 @@ +[[creating-a-basic-application]] +Creating a basic application +---------------------------- + +To create a Vaadin application you need two files. A class that extends +UI which is your main view and entry point to the application as well as +a web.xml referring to the UI. + +With Eclipse and the Vaadin plugin you will get all of this +automatically by opening the New wizard (File -> New -> Other) and +choosing Vaadin -> Vaadin Project. From there you can give the new +project a name and the wizard takes care of the rest. + +In other environments you can create the standard java web application +project. Create one file which extends UI into the source folder. Let's +call it MyApplicationUI: + +[source,java] +.... +package com.example.myexampleproject; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.Label; + +public class MyApplicationUI extends UI { + + @Override + protected void init(VaadinRequest request) { + VerticalLayout view = new VerticalLayout(); + view.addComponent(new Label("Hello Vaadin!")); + setContent(view); + } +} +.... + +This application creates a new main layout to the UI and adds the text +"Hello Vaadin!" into it. + +Your web deployment descriptor, web.xml, has to point at your UI as +well. This is done with an defining a Vaadin servlet and giving the UI +as a parameter to it: + +[source,xml] +.... +<?xml version="1.0" encoding="UTF-8"?> +<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" +xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> + <display-name>MyApplication</display-name> + <context-param> + <description>Vaadin production mode</description> + <param-name>productionMode</param-name> + <param-value>false</param-value> + </context-param> + <servlet> + <servlet-name>My Vaadin App</servlet-name> + <servlet-class>com.vaadin.server.VaadinServlet</servlet-class> + <init-param> + <description>Vaadin UI</description> + <param-name>UI</param-name> + <param-value>com.example.myexampleproject.MyApplicationUI</param-value> + </init-param> + </servlet> + <servlet-mapping> + <servlet-name>My Vaadin App</servlet-name> + <url-pattern>/*</url-pattern> + </servlet-mapping> +</web-app> +.... + +Now you're able to package your application into a war and deploy it on +a servlet container. diff --git a/documentation/articles/contents.asciidoc b/documentation/articles/contents.asciidoc index 3567389f02..bbd59e616b 100644 --- a/documentation/articles/contents.asciidoc +++ b/documentation/articles/contents.asciidoc @@ -10,3 +10,4 @@ - link:CreatingAnApplicationWithDifferentFeaturesForDifferentClients.asciidoc[Creating an application with different features for different clients] - link:VAccessControl.asciidoc[V - Access control] - link:FindingTheCurrentRootAndApplication.asciidoc[Finding the current root and application] +- link:CreatingABasicApplication.asciidoc[Creating a basic application] |