From b92d3d6745b4f375303ae34290c1f8050b3c25e1 Mon Sep 17 00:00:00 2001 From: tatulund Date: Fri, 25 Oct 2019 10:46:57 +0300 Subject: [PATCH 1/3] Added Wildfly plugin, Updated to Vaadin 14.0.9 compatibility mode, Added custom servlet example, updated README.md --- README.md | 5 +++ pom.xml | 15 ++++++- .../org/vaadin/cdi/tutorial/MyServlet.java | 41 +++++++++++++++++++ 3 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 src/main/java/org/vaadin/cdi/tutorial/MyServlet.java diff --git a/README.md b/README.md index e35c547..0a13ae3 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,13 @@ The topics that are covered in this tutorial project: * Register VaadinServiceInitListener via CDI Observer * Flow template within CDI * Use I18N in CDI +* Extending servlet ## Running the project from command line Run `mvn clean package tomee:run` in the project root directory. After the server has started point your browser to [http://localhost:8080](http://localhost:8080) to see the resulting application. +or + +Run ``mvn clean package wildfly:run` in the project root directory. After the server has started point your browser to [http://localhost:8080/cdi.tutorial-1.0.0-SNAPSHOT/](http://localhost:8080/cdi.tutorial-1.0.0-SNAPSHOT/) to see the resulting application. + diff --git a/pom.xml b/pom.xml index 9f4e071..70d5ec1 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ src/main/webapp - 10.0.3 + 14.0.9 1.0.3 @@ -53,10 +53,13 @@ com.vaadin vaadin-core + + com.vaadin + flow-server-compatibility-mode + com.vaadin vaadin-cdi - 10.0.0.beta1 javax @@ -74,6 +77,14 @@ + + org.wildfly.plugins + wildfly-maven-plugin + 2.0.0.Final + + 15.0.0.Final + + org.apache.tomee.maven tomee-maven-plugin diff --git a/src/main/java/org/vaadin/cdi/tutorial/MyServlet.java b/src/main/java/org/vaadin/cdi/tutorial/MyServlet.java new file mode 100644 index 0000000..2824b3c --- /dev/null +++ b/src/main/java/org/vaadin/cdi/tutorial/MyServlet.java @@ -0,0 +1,41 @@ +package org.vaadin.cdi.tutorial; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; + +import com.vaadin.cdi.CdiVaadinServlet; +import com.vaadin.flow.server.CustomizedSystemMessages; +import com.vaadin.flow.server.SystemMessages; +import com.vaadin.flow.server.SystemMessagesInfo; +import com.vaadin.flow.server.SystemMessagesProvider; + +@WebServlet(urlPatterns = {"/*","/frontend/*"}, asyncSupported = true) +public class MyServlet extends CdiVaadinServlet { + + @Override + protected void servletInitialized() throws ServletException + { + super.servletInitialized(); + + this.getService().setSystemMessagesProvider(new SystemMessagesProvider() { + + @Override + public SystemMessages getSystemMessages(SystemMessagesInfo systemMessagesInfo) { + CustomizedSystemMessages messages = new CustomizedSystemMessages(); + messages.setSessionExpiredCaption("Sitzung abgelaufen"); + messages.setSessionExpiredMessage("Bitte notieren Sie ungespeicherte Daten und klicken Sie hier oder drücken Sie die ESC-Taste..."); + messages.setSessionExpiredNotificationEnabled(true); + messages.setInternalErrorCaption("Kommunikationsfehler"); + messages.setInternalErrorMessage("Bitte notieren Sie ungespeicherte Daten und klicken Sie hier oder drücken Sie die ESC-Taste..."); + messages.setInternalErrorNotificationEnabled(true); + messages.setCookiesDisabledCaption("Cookies sind abgeschaltet"); + messages.setCookiesDisabledMessage("Diese Anwendung benötigt Cookies, um korrekt zu funktionieren.
Bitte schalten Sie Cookies in Ihrem Browser ein und klicken Sie hier oder drücken Sie die ESC-Taste..."); + messages.setCookiesDisabledNotificationEnabled(true); + messages.setInternalErrorCaption("Interner Fehler"); + messages.setInternalErrorMessage("Informieren Sie Ihren Anwendungsbetreuer.
Bitte notieren Sie ungespeicherte Daten und klicken Sie hier oder drücken Sie die ESC-Taste..."); + messages.setInternalErrorNotificationEnabled(true); + return messages; + } + }); + } +} From 7688de85e20ca50abe5f7702ecc882255b5fc1d5 Mon Sep 17 00:00:00 2001 From: tatulund Date: Tue, 26 Jul 2022 15:24:13 +0300 Subject: [PATCH 2/3] Converted not to use compatibility mode, updated to the latest Vaadin 14 version --- frontend/example-template.js | 13 +++++++ pom.xml | 35 +++++++++++-------- .../vaadin/cdi/tutorial/ExampleTemplate.java | 5 ++- .../vaadin/cdi/tutorial/RootComponent.java | 3 +- src/main/webapp/frontend/ExampleTemplate.html | 35 ------------------- 5 files changed, 36 insertions(+), 55 deletions(-) create mode 100644 frontend/example-template.js delete mode 100644 src/main/webapp/frontend/ExampleTemplate.html diff --git a/frontend/example-template.js b/frontend/example-template.js new file mode 100644 index 0000000..bf65305 --- /dev/null +++ b/frontend/example-template.js @@ -0,0 +1,13 @@ +import { html, PolymerElement } from '@polymer/polymer'; + +export class ExampleTemplate extends PolymerElement { + static get is() { + return 'example-template' + } + + static get template() { + return html`[[message]]`; + } +} + +customElements.define(ExampleTemplate.is, ExampleTemplate); \ No newline at end of file diff --git a/pom.xml b/pom.xml index 70d5ec1..f10510c 100644 --- a/pom.xml +++ b/pom.xml @@ -18,8 +18,7 @@ src/main/webapp - 14.0.9 - 1.0.3 + 14.8.14 @@ -53,10 +52,6 @@ com.vaadin vaadin-core
- - com.vaadin - flow-server-compatibility-mode - com.vaadin vaadin-cdi @@ -64,7 +59,7 @@ javax javaee-api - 7.0 + 8.0 provided @@ -77,6 +72,22 @@ + + com.vaadin + vaadin-maven-plugin + ${vaadin.version} + + true + true + + + + + prepare-frontend + + + + org.wildfly.plugins wildfly-maven-plugin @@ -132,18 +143,12 @@ com.vaadin - flow-maven-plugin - ${flow.maven.plugin.version} + vaadin-maven-plugin - prepare-package - copy-production-files - package-for-production + build-frontend - - ${webapp.directory} - diff --git a/src/main/java/org/vaadin/cdi/tutorial/ExampleTemplate.java b/src/main/java/org/vaadin/cdi/tutorial/ExampleTemplate.java index f45cdd7..710a1cb 100644 --- a/src/main/java/org/vaadin/cdi/tutorial/ExampleTemplate.java +++ b/src/main/java/org/vaadin/cdi/tutorial/ExampleTemplate.java @@ -16,7 +16,7 @@ package org.vaadin.cdi.tutorial; import com.vaadin.flow.component.Tag; -import com.vaadin.flow.component.dependency.HtmlImport; +import com.vaadin.flow.component.dependency.JsModule; import com.vaadin.flow.component.polymertemplate.PolymerTemplate; import com.vaadin.flow.templatemodel.TemplateModel; import org.vaadin.cdi.tutorial.ExampleTemplate.ExampleModel; @@ -27,14 +27,13 @@ * Simple template example. */ @Tag("example-template") -@HtmlImport("frontend://ExampleTemplate.html") +@JsModule("./example-template.js") public class ExampleTemplate extends PolymerTemplate { /** * Template model which defines the single "name" property. */ public interface ExampleModel extends TemplateModel { - void setMessage(String message); } diff --git a/src/main/java/org/vaadin/cdi/tutorial/RootComponent.java b/src/main/java/org/vaadin/cdi/tutorial/RootComponent.java index 5f5babf..324e2ee 100644 --- a/src/main/java/org/vaadin/cdi/tutorial/RootComponent.java +++ b/src/main/java/org/vaadin/cdi/tutorial/RootComponent.java @@ -46,12 +46,11 @@ public RootComponent(UiGreeter uiGreeter, ExampleTemplate template) { getTranslation("root.navigate_to_component"), ParentView.class); - Style linkStyle = link.getElement().getStyle(); + Style linkStyle = link.getStyle(); linkStyle.set("display", "block"); linkStyle.set("margin-bottom", "10px"); add(greeting, button, link, template); - add(template); } @Override diff --git a/src/main/webapp/frontend/ExampleTemplate.html b/src/main/webapp/frontend/ExampleTemplate.html deleted file mode 100644 index 7f3be4a..0000000 --- a/src/main/webapp/frontend/ExampleTemplate.html +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - From ed6d777566870f28a1472ee3b046976d082611f3 Mon Sep 17 00:00:00 2001 From: tatulund Date: Tue, 26 Jul 2022 15:28:34 +0300 Subject: [PATCH 3/3] Formatting --- pom.xml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index f10510c..bd65aba 100644 --- a/pom.xml +++ b/pom.xml @@ -88,14 +88,14 @@ - - org.wildfly.plugins - wildfly-maven-plugin - 2.0.0.Final - - 15.0.0.Final - - + + org.wildfly.plugins + wildfly-maven-plugin + 2.0.0.Final + + 15.0.0.Final + + org.apache.tomee.maven tomee-maven-plugin @@ -147,7 +147,7 @@ - build-frontend + build-frontend