diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2017-03-14 10:00:27 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2017-03-14 10:00:27 +0100 |
commit | 66503524db1c667d6e2282b333d1aca3ec284fcb (patch) | |
tree | 1fc00e5a759b48780074f10e27afac4408250a25 /java/vaadin/src | |
parent | 09c4b4be9ec33bac7d814dbeb28095a7a7add835 (diff) | |
download | share-66503524db1c667d6e2282b333d1aca3ec284fcb.zip share-66503524db1c667d6e2282b333d1aca3ec284fcb.tar.gz |
java : vaadin : add HelloWorldServlet
Diffstat (limited to 'java/vaadin/src')
-rw-r--r-- | java/vaadin/src/main/WebContent/WEB-INF/web.xml | 28 | ||||
-rw-r--r-- | java/vaadin/src/main/java/ch/asynk/HelloWorld.java | 2 | ||||
-rw-r--r-- | java/vaadin/src/main/java/ch/asynk/HelloWorldServlet.java | 37 |
3 files changed, 46 insertions, 21 deletions
diff --git a/java/vaadin/src/main/WebContent/WEB-INF/web.xml b/java/vaadin/src/main/WebContent/WEB-INF/web.xml index f4b7f85..6e03c3d 100644 --- a/java/vaadin/src/main/WebContent/WEB-INF/web.xml +++ b/java/vaadin/src/main/WebContent/WEB-INF/web.xml @@ -19,27 +19,13 @@ <!-- <tracking-mode>COOKIE</tracking-mode> --> </session-config> - <servlet> - <servlet-name>default</servlet-name> - <servlet-class>com.vaadin.server.VaadinServlet</servlet-class> - <init-param> - <description>Vaadin application class to start</description> - <param-name>UI</param-name> - <param-value>ch.asynk.HelloWorld</param-value> - </init-param> - <async-supported>true</async-supported> - </servlet> - <servlet-mapping> - <servlet-name>default</servlet-name> - <url-pattern>/*</url-pattern> - </servlet-mapping> <!-- <welcome-file-list> --> - <!-- <welcome-file>index.html</welcome-file> --> - <!-- <welcome-file>index.htm</welcome-file> --> - <!-- <welcome-file>index.jsp</welcome-file> --> - <!-- <welcome-file>default.html</welcome-file> --> - <!-- <welcome-file>default.htm</welcome-file> --> - <!-- <welcome-file>default.jsp</welcome-file> --> - <!-- </welcome-file-list> --> + <!-- <welcome-file>index.html</welcome-file> --> + <!-- <welcome-file>index.htm</welcome-file> --> + <!-- <welcome-file>index.jsp</welcome-file> --> + <!-- <welcome-file>default.html</welcome-file> --> + <!-- <welcome-file>default.htm</welcome-file> --> + <!-- <welcome-file>default.jsp</welcome-file> --> + <!-- </welcome-file-list> --> </web-app> diff --git a/java/vaadin/src/main/java/ch/asynk/HelloWorld.java b/java/vaadin/src/main/java/ch/asynk/HelloWorld.java index f15bddd..c9f807e 100644 --- a/java/vaadin/src/main/java/ch/asynk/HelloWorld.java +++ b/java/vaadin/src/main/java/ch/asynk/HelloWorld.java @@ -1,5 +1,6 @@ package ch.asynk; +import com.vaadin.annotations.PreserveOnRefresh; import com.vaadin.annotations.Theme; import com.vaadin.annotations.Title; import com.vaadin.server.VaadinRequest; @@ -15,6 +16,7 @@ import com.vaadin.ui.VerticalLayout; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +@PreserveOnRefresh @Title("Hello!!") @Theme("mytheme") public class HelloWorld extends UI diff --git a/java/vaadin/src/main/java/ch/asynk/HelloWorldServlet.java b/java/vaadin/src/main/java/ch/asynk/HelloWorldServlet.java new file mode 100644 index 0000000..e4092f2 --- /dev/null +++ b/java/vaadin/src/main/java/ch/asynk/HelloWorldServlet.java @@ -0,0 +1,37 @@ +package ch.asynk; + +import javax.servlet.annotation.WebServlet; +import javax.servlet.ServletException; + +import com.vaadin.annotations.VaadinServletConfiguration; +import com.vaadin.server.ServiceException; +import com.vaadin.server.SessionInitEvent; +import com.vaadin.server.SessionInitListener; +import com.vaadin.server.SessionDestroyEvent; +import com.vaadin.server.SessionDestroyListener; +import com.vaadin.server.VaadinServlet; + +@WebServlet(value = "/*", asyncSupported = true) +@VaadinServletConfiguration(productionMode = false, ui = ch.asynk.HelloWorld.class, closeIdleSessions = true) +public class HelloWorldServlet extends VaadinServlet implements SessionInitListener, SessionDestroyListener +{ + private static final long serialVersionUID = 511085337415583793L; + @Override + protected void servletInitialized() throws ServletException { + super.servletInitialized(); + getService().addSessionInitListener(this); + getService().addSessionDestroyListener(this); + } + + @Override + public void sessionInit(SessionInitEvent event) throws ServiceException + { + event.getSession().setLocale(new java.util.Locale("fr", "CH")); + System.err.println("sessionInit"); + } + + @Override + public void sessionDestroy(SessionDestroyEvent event) { + System.err.println("sessionDestroy"); + } +} |