initial upload
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
commit
2bfdf6b9de
|
|
@ -0,0 +1,46 @@
|
||||||
|
# ---> VisualStudioCode
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
||||||
|
!.vscode/*.code-snippets
|
||||||
|
|
||||||
|
# Local History for Visual Studio Code
|
||||||
|
.history/
|
||||||
|
|
||||||
|
# Built Visual Studio Code Extensions
|
||||||
|
*.vsix
|
||||||
|
|
||||||
|
HELP.md
|
||||||
|
target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
!**/src/main/**/target/
|
||||||
|
!**/src/test/**/target/
|
||||||
|
|
||||||
|
### STS ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
build/
|
||||||
|
!**/src/main/**/build/
|
||||||
|
!**/src/test/**/build/
|
||||||
|
|
||||||
|
*.DS_Store
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"type": "java",
|
||||||
|
"name": "Current File",
|
||||||
|
"request": "launch",
|
||||||
|
"mainClass": "${file}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
{
|
||||||
|
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||||
|
// for the documentation about the tasks.json format
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "start app server",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "mvn jetty:run -pl *-server -am -Denv=dev",
|
||||||
|
"group": "test"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "start gwt code server",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "mvn gwt:codeserver -pl *-client -am",
|
||||||
|
"group": "test"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>space.barrx</groupId>
|
||||||
|
<artifactId>gwtdemo</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>gwtdemo-client</artifactId>
|
||||||
|
<packaging>gwt-app</packaging>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>gwtdemo-shared</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>gwtdemo-shared</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<classifier>sources</classifier>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gwtproject</groupId>
|
||||||
|
<artifactId>gwt-user</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gwtproject</groupId>
|
||||||
|
<artifactId>gwt-dev</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>net.ltgt.gwt.maven</groupId>
|
||||||
|
<artifactId>gwt-maven-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<moduleName>space.barrx.gwtdemo.App</moduleName>
|
||||||
|
<moduleShortName>gwtapp</moduleShortName>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
|
|
@ -0,0 +1,163 @@
|
||||||
|
package space.barrx.gwtdemo;
|
||||||
|
|
||||||
|
import com.google.gwt.core.client.EntryPoint;
|
||||||
|
import com.google.gwt.core.client.GWT;
|
||||||
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
|
import com.google.gwt.event.dom.client.KeyCodes;
|
||||||
|
import com.google.gwt.event.dom.client.KeyUpEvent;
|
||||||
|
import com.google.gwt.event.dom.client.KeyUpHandler;
|
||||||
|
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
||||||
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
import com.google.gwt.user.client.ui.Button;
|
||||||
|
import com.google.gwt.user.client.ui.DialogBox;
|
||||||
|
import com.google.gwt.user.client.ui.HTML;
|
||||||
|
import com.google.gwt.user.client.ui.Label;
|
||||||
|
import com.google.gwt.user.client.ui.RootPanel;
|
||||||
|
import com.google.gwt.user.client.ui.TextBox;
|
||||||
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Entry point classes define <code>onModuleLoad()</code>.
|
||||||
|
*/
|
||||||
|
public class App implements EntryPoint {
|
||||||
|
/**
|
||||||
|
* The message displayed to the user when the server cannot be reached or
|
||||||
|
* returns an error.
|
||||||
|
*/
|
||||||
|
private static final String SERVER_ERROR = "An error occurred while "
|
||||||
|
+ "attempting to contact the server. Please check your network "
|
||||||
|
+ "connection and try again.";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a remote service proxy to talk to the server-side Greeting service.
|
||||||
|
*/
|
||||||
|
private final GreetingServiceAsync greetingService = GWT
|
||||||
|
.create(GreetingService.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the entry point method.
|
||||||
|
*/
|
||||||
|
public void onModuleLoad() {
|
||||||
|
// Create and add the menu presenter
|
||||||
|
MenuViewImpl menuView = new MenuViewImpl();
|
||||||
|
MenuPresenter menuPresenter = new MenuPresenter(menuView);
|
||||||
|
RootPanel.get("menuContainer").add(menuView);
|
||||||
|
|
||||||
|
final Button sendButton = new Button("Send");
|
||||||
|
final TextBox nameField = new TextBox();
|
||||||
|
nameField.setText("GWT User");
|
||||||
|
final Label errorLabel = new Label();
|
||||||
|
|
||||||
|
// We can add style names to widgets
|
||||||
|
sendButton.addStyleName("sendButton");
|
||||||
|
|
||||||
|
// Add the nameField and sendButton to the RootPanel
|
||||||
|
// Use RootPanel.get() to get the entire body element
|
||||||
|
RootPanel.get("nameFieldContainer").add(nameField);
|
||||||
|
RootPanel.get("sendButtonContainer").add(sendButton);
|
||||||
|
RootPanel.get("errorLabelContainer").add(errorLabel);
|
||||||
|
|
||||||
|
// Focus the cursor on the name field when the app loads
|
||||||
|
nameField.setFocus(true);
|
||||||
|
nameField.selectAll();
|
||||||
|
|
||||||
|
// Create the popup dialog box
|
||||||
|
final DialogBox dialogBox = new DialogBox();
|
||||||
|
dialogBox.setText("Remote Procedure Call");
|
||||||
|
dialogBox.setAnimationEnabled(true);
|
||||||
|
final Button closeButton = new Button("Close");
|
||||||
|
// We can set the id of a widget by accessing its Element
|
||||||
|
closeButton.getElement().setId("closeButton");
|
||||||
|
final Label textToServerLabel = new Label();
|
||||||
|
final HTML serverResponseLabel = new HTML();
|
||||||
|
VerticalPanel dialogVPanel = new VerticalPanel();
|
||||||
|
dialogVPanel.addStyleName("dialogVPanel");
|
||||||
|
dialogVPanel.add(new HTML("<b>Sending name to the server:</b>"));
|
||||||
|
dialogVPanel.add(textToServerLabel);
|
||||||
|
dialogVPanel.add(new HTML("<br><b>Server replies:</b>"));
|
||||||
|
dialogVPanel.add(serverResponseLabel);
|
||||||
|
dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT);
|
||||||
|
dialogVPanel.add(closeButton);
|
||||||
|
dialogBox.setWidget(dialogVPanel);
|
||||||
|
|
||||||
|
// Add a handler to close the DialogBox
|
||||||
|
closeButton.addClickHandler(new ClickHandler() {
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
dialogBox.hide();
|
||||||
|
sendButton.setEnabled(true);
|
||||||
|
sendButton.setFocus(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create a handler for the sendButton and nameField
|
||||||
|
class MyHandler implements ClickHandler, KeyUpHandler {
|
||||||
|
/**
|
||||||
|
* Fired when the user clicks on the sendButton.
|
||||||
|
*/
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
sendNameToServer();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fired when the user types in the nameField.
|
||||||
|
*/
|
||||||
|
public void onKeyUp(KeyUpEvent event) {
|
||||||
|
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
|
||||||
|
sendNameToServer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send the name from the nameField to the server and wait for a response.
|
||||||
|
*/
|
||||||
|
private void sendNameToServer() {
|
||||||
|
// First, we validate the input.
|
||||||
|
errorLabel.setText("");
|
||||||
|
String textToServer = nameField.getText();
|
||||||
|
if (!FieldVerifier.isValidName(textToServer)) {
|
||||||
|
errorLabel.setText("Please enter at least four characters");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Then, we send the input to the server.
|
||||||
|
sendButton.setEnabled(false);
|
||||||
|
textToServerLabel.setText(textToServer);
|
||||||
|
serverResponseLabel.setText("");
|
||||||
|
greetingService.greetServer(textToServer,
|
||||||
|
new AsyncCallback<GreetingResponse>() {
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
// Show the RPC error message to the user
|
||||||
|
dialogBox
|
||||||
|
.setText("Remote Procedure Call - Failure");
|
||||||
|
serverResponseLabel
|
||||||
|
.addStyleName("serverResponseLabelError");
|
||||||
|
serverResponseLabel.setHTML(SERVER_ERROR);
|
||||||
|
dialogBox.center();
|
||||||
|
closeButton.setFocus(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onSuccess(GreetingResponse result) {
|
||||||
|
dialogBox.setText("Remote Procedure Call");
|
||||||
|
serverResponseLabel
|
||||||
|
.removeStyleName("serverResponseLabelError");
|
||||||
|
serverResponseLabel.setHTML(new SafeHtmlBuilder()
|
||||||
|
.appendEscaped(result.getGreeting())
|
||||||
|
.appendHtmlConstant("<br><br>I am running ")
|
||||||
|
.appendEscaped(result.getServerInfo())
|
||||||
|
.appendHtmlConstant(".<br><br>It looks like you are using:<br>")
|
||||||
|
.appendEscaped(result.getUserAgent())
|
||||||
|
.toSafeHtml());
|
||||||
|
dialogBox.center();
|
||||||
|
closeButton.setFocus(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add a handler to send the name to the server
|
||||||
|
MyHandler handler = new MyHandler();
|
||||||
|
sendButton.addClickHandler(handler);
|
||||||
|
nameField.addKeyUpHandler(handler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
package space.barrx.gwtdemo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handler for menu item actions.
|
||||||
|
*/
|
||||||
|
public interface MenuItemHandler {
|
||||||
|
void onMenuItemClicked(String itemLabel);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,68 @@
|
||||||
|
package space.barrx.gwtdemo;
|
||||||
|
|
||||||
|
import com.google.gwt.core.client.GWT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Presenter for the Menu in MVP pattern.
|
||||||
|
* Handles menu logic and coordinates between the view and the application.
|
||||||
|
*/
|
||||||
|
public class MenuPresenter {
|
||||||
|
private MenuView view;
|
||||||
|
|
||||||
|
public MenuPresenter(MenuView view) {
|
||||||
|
this.view = view;
|
||||||
|
view.setPresenter(this);
|
||||||
|
setupMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the menu with default items.
|
||||||
|
*/
|
||||||
|
private void setupMenu() {
|
||||||
|
view.addMenuItem("Home", new MenuItemHandler() {
|
||||||
|
@Override
|
||||||
|
public void onMenuItemClicked(String itemLabel) {
|
||||||
|
onHomeClicked();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
view.addMenuItem("About", new MenuItemHandler() {
|
||||||
|
@Override
|
||||||
|
public void onMenuItemClicked(String itemLabel) {
|
||||||
|
onAboutClicked();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
view.addMenuItem("Settings", new MenuItemHandler() {
|
||||||
|
@Override
|
||||||
|
public void onMenuItemClicked(String itemLabel) {
|
||||||
|
onSettingsClicked();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle Home menu item click.
|
||||||
|
*/
|
||||||
|
private void onHomeClicked() {
|
||||||
|
GWT.log("Home menu item clicked");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle About menu item click.
|
||||||
|
*/
|
||||||
|
private void onAboutClicked() {
|
||||||
|
GWT.log("About menu item clicked");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle Settings menu item click.
|
||||||
|
*/
|
||||||
|
private void onSettingsClicked() {
|
||||||
|
GWT.log("Settings menu item clicked");
|
||||||
|
}
|
||||||
|
|
||||||
|
public MenuView getView() {
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
package space.barrx.gwtdemo;
|
||||||
|
|
||||||
|
import com.google.gwt.user.client.ui.IsWidget;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* View interface for the Menu in MVP pattern.
|
||||||
|
*/
|
||||||
|
public interface MenuView extends IsWidget {
|
||||||
|
/**
|
||||||
|
* Set the presenter that will handle menu actions.
|
||||||
|
*/
|
||||||
|
void setPresenter(MenuPresenter presenter);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a menu item with the given label and action handler.
|
||||||
|
*/
|
||||||
|
void addMenuItem(String label, MenuItemHandler handler);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
package space.barrx.gwtdemo;
|
||||||
|
|
||||||
|
import com.google.gwt.safehtml.shared.SafeHtml;
|
||||||
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
|
import com.google.gwt.user.client.ui.MenuBar;
|
||||||
|
import com.google.gwt.user.client.ui.MenuItem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of MenuView using GWT's MenuBar widget.
|
||||||
|
*/
|
||||||
|
public class MenuViewImpl extends Composite implements MenuView {
|
||||||
|
private MenuBar menu;
|
||||||
|
private MenuPresenter presenter;
|
||||||
|
|
||||||
|
public MenuViewImpl() {
|
||||||
|
menu = new MenuBar();
|
||||||
|
menu.addStyleName("mainMenu");
|
||||||
|
initWidget(menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPresenter(MenuPresenter presenter) {
|
||||||
|
this.presenter = presenter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addMenuItem(String label, final MenuItemHandler handler) {
|
||||||
|
|
||||||
|
MenuItem item = new MenuItem(new SafeHtml() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String asString() {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
item.setScheduledCommand(() -> handler.onMenuItemClicked(label));
|
||||||
|
menu.addItem(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module>
|
||||||
|
<inherits name="com.google.gwt.user.User" />
|
||||||
|
<inherits name="com.google.gwt.user.theme.clean.Clean" />
|
||||||
|
|
||||||
|
<source path="" />
|
||||||
|
|
||||||
|
<entry-point class="space.barrx.gwtdemo.App" />
|
||||||
|
|
||||||
|
<!-- Only support recent browsers -->
|
||||||
|
<set-property name="user.agent" value="gecko1_8,safari" />
|
||||||
|
</module>
|
||||||
|
|
@ -0,0 +1,91 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>space.barrx</groupId>
|
||||||
|
<artifactId>gwtdemo</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>gwtdemo-server</artifactId>
|
||||||
|
<packaging>war</packaging>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>gwtdemo-shared</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gwtproject</groupId>
|
||||||
|
<artifactId>gwt-servlet-jakarta</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.servlet</groupId>
|
||||||
|
<artifactId>jakarta.servlet-api</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<pluginManagement>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.eclipse.jetty.ee10</groupId>
|
||||||
|
<artifactId>jetty-ee10-maven-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<scan>1</scan>
|
||||||
|
<contextXml>${basedir}/src/main/jettyconf/context.xml</contextXml>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</pluginManagement>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<!-- XXX: We want to exclude gwtdemo-client from 'env-dev' profile, Maven forces us to make a 'env-prod' profile -->
|
||||||
|
<id>env-prod</id>
|
||||||
|
<activation>
|
||||||
|
<activeByDefault>true</activeByDefault>
|
||||||
|
</activation>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>gwtdemo-client</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>war</type>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</profile>
|
||||||
|
<profile>
|
||||||
|
<id>env-dev</id>
|
||||||
|
<activation>
|
||||||
|
<property>
|
||||||
|
<name>env</name>
|
||||||
|
<value>dev</value>
|
||||||
|
</property>
|
||||||
|
</activation>
|
||||||
|
<build>
|
||||||
|
<pluginManagement>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.eclipse.jetty.ee10</groupId>
|
||||||
|
<artifactId>jetty-ee10-maven-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<webApp>
|
||||||
|
<resourceBases>
|
||||||
|
<resourceBase>${basedir}/src/main/webapp</resourceBase>
|
||||||
|
<resourceBase>${project.build.directory}/gwt/launcherDir/</resourceBase>
|
||||||
|
</resourceBases>
|
||||||
|
</webApp>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</pluginManagement>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
</project>
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
package space.barrx.gwtdemo;
|
||||||
|
|
||||||
|
import com.google.gwt.user.server.rpc.jakarta.RemoteServiceServlet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The server side implementation of the RPC service.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
public class GreetingServiceImpl extends RemoteServiceServlet implements
|
||||||
|
GreetingService {
|
||||||
|
|
||||||
|
public GreetingResponse greetServer(String input) throws IllegalArgumentException {
|
||||||
|
// Verify that the input is valid.
|
||||||
|
if (!FieldVerifier.isValidName(input)) {
|
||||||
|
// If the input is not valid, throw an IllegalArgumentException back to
|
||||||
|
// the client.
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
"Name must be at least 4 characters long");
|
||||||
|
}
|
||||||
|
|
||||||
|
GreetingResponse response = new GreetingResponse();
|
||||||
|
|
||||||
|
response.setServerInfo(getServletContext().getServerInfo());
|
||||||
|
response.setUserAgent(getThreadLocalRequest().getHeader("User-Agent"));
|
||||||
|
|
||||||
|
response.setGreeting("Hello, " + input + "!");
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://jetty.org/configure_10_0.dtd">
|
||||||
|
<Configure class="org.eclipse.jetty.ee10.webapp.WebAppContext">
|
||||||
|
<Call name="setInitParameter">
|
||||||
|
<Arg>org.eclipse.jetty.servlet.Default.useFileMappedBuffer</Arg>
|
||||||
|
<Arg>false</Arg>
|
||||||
|
</Call>
|
||||||
|
</Configure>
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<web-app xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"
|
||||||
|
version="5.0">
|
||||||
|
|
||||||
|
<!-- Servlets -->
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>greetServlet</servlet-name>
|
||||||
|
<servlet-class>space.barrx.gwtdemo.GreetingServiceImpl</servlet-class>
|
||||||
|
</servlet>
|
||||||
|
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>greetServlet</servlet-name>
|
||||||
|
<url-pattern>/gwtapp/greet</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
|
||||||
|
<!-- Default page to serve -->
|
||||||
|
<welcome-file-list>
|
||||||
|
<welcome-file>index.html</welcome-file>
|
||||||
|
</welcome-file-list>
|
||||||
|
|
||||||
|
</web-app>
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
|
|
@ -0,0 +1,50 @@
|
||||||
|
/** Add css rules here for your application. */
|
||||||
|
|
||||||
|
|
||||||
|
/** Example rules used by the template application (remove for your app) */
|
||||||
|
h1 {
|
||||||
|
font-size: 2em;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #777777;
|
||||||
|
margin: 40px 0px 70px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sendButton {
|
||||||
|
display: block;
|
||||||
|
font-size: 16pt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Most GWT widgets already have a style name defined */
|
||||||
|
.gwt-DialogBox {
|
||||||
|
width: 400px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dialogVPanel {
|
||||||
|
margin: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.serverResponseLabelError {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Set ids using widget.getElement().setId("idOfElement") */
|
||||||
|
#closeButton {
|
||||||
|
margin: 15px 6px 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Menu styles */
|
||||||
|
.mainMenu {
|
||||||
|
background-color: #f0f0f0;
|
||||||
|
border-bottom: 2px solid #333;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mainMenu .gwt-MenuItem {
|
||||||
|
padding: 5px 15px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mainMenu .gwt-MenuItem:hover {
|
||||||
|
background-color: #ddd;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
<!doctype html>
|
||||||
|
<!-- The DOCTYPE declaration above will set the -->
|
||||||
|
<!-- browser's rendering engine into -->
|
||||||
|
<!-- "Standards Mode". Replacing this declaration -->
|
||||||
|
<!-- with a "Quirks Mode" doctype is not supported. -->
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset=UTF-8>
|
||||||
|
|
||||||
|
<!-- -->
|
||||||
|
<!-- Consider inlining CSS to reduce the number of requested files -->
|
||||||
|
<!-- -->
|
||||||
|
<link type="text/css" rel="stylesheet" href="gwtdemo.css">
|
||||||
|
|
||||||
|
<!-- -->
|
||||||
|
<!-- Any title is fine -->
|
||||||
|
<!-- -->
|
||||||
|
<title>Web Application Starter Project</title>
|
||||||
|
|
||||||
|
<!-- -->
|
||||||
|
<!-- This script loads your compiled module. -->
|
||||||
|
<!-- If you add any GWT meta tags, they must -->
|
||||||
|
<!-- be added before this line. -->
|
||||||
|
<!-- -->
|
||||||
|
<script src="gwtapp/gwtapp.nocache.js"></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<!-- -->
|
||||||
|
<!-- The body can have arbitrary html, or -->
|
||||||
|
<!-- you can leave the body empty if you want -->
|
||||||
|
<!-- to create a completely dynamic UI. -->
|
||||||
|
<!-- -->
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<!-- RECOMMENDED if your web app will not function without JavaScript enabled -->
|
||||||
|
<noscript>
|
||||||
|
<div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif">
|
||||||
|
Your web browser must have JavaScript enabled
|
||||||
|
in order for this application to display correctly.
|
||||||
|
</div>
|
||||||
|
</noscript>
|
||||||
|
|
||||||
|
<div id="menuContainer" style="margin-bottom: 20px;"></div>
|
||||||
|
|
||||||
|
<h1>Web Application Starter Project</h1>
|
||||||
|
|
||||||
|
<table align="center">
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" style="font-weight:bold;">Please enter your name:</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td id="nameFieldContainer"></td>
|
||||||
|
<td id="sendButtonContainer"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" style="color:red;" id="errorLabelContainer"></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>space.barrx</groupId>
|
||||||
|
<artifactId>gwtdemo</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>gwtdemo-shared</artifactId>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gwtproject</groupId>
|
||||||
|
<artifactId>gwt-servlet-jakarta</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
package space.barrx.gwtdemo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* FieldVerifier validates that the name the user enters is valid.
|
||||||
|
* </p>
|
||||||
|
* <p>
|
||||||
|
* This class is in the <code>shared</code> project because we use it in both
|
||||||
|
* the client code and on the server. On the client, we verify that the name is
|
||||||
|
* valid before sending an RPC request so the user doesn't have to wait for a
|
||||||
|
* network round trip to get feedback. On the server, we verify that the name is
|
||||||
|
* correct to ensure that the input is correct regardless of where the RPC
|
||||||
|
* originates.
|
||||||
|
* </p>
|
||||||
|
* <p>
|
||||||
|
* When creating a class that is used on both the client and the server, be sure
|
||||||
|
* that all code is translatable and does not use native JavaScript. Code that
|
||||||
|
* is not translatable (such as code that interacts with a database or the file
|
||||||
|
* system) cannot be compiled into client side JavaScript. Code that uses native
|
||||||
|
* JavaScript (such as Widgets) cannot be run on the server.
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
|
public class FieldVerifier {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verifies that the specified name is valid for our service.
|
||||||
|
*
|
||||||
|
* In this example, we only require that the name is at least four
|
||||||
|
* characters. In your application, you can use more complex checks to ensure
|
||||||
|
* that usernames, passwords, email addresses, URLs, and other fields have the
|
||||||
|
* proper syntax.
|
||||||
|
*
|
||||||
|
* @param name the name to validate
|
||||||
|
* @return true if valid, false if invalid
|
||||||
|
*/
|
||||||
|
public static boolean isValidName(String name) {
|
||||||
|
if (name == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return name.length() > 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
package space.barrx.gwtdemo;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
public class GreetingResponse implements Serializable {
|
||||||
|
private String greeting;
|
||||||
|
private String serverInfo;
|
||||||
|
private String userAgent;
|
||||||
|
|
||||||
|
public String getGreeting() {
|
||||||
|
return greeting;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGreeting(String greeting) {
|
||||||
|
this.greeting = greeting;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getServerInfo() {
|
||||||
|
return serverInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setServerInfo(String serverInfo) {
|
||||||
|
this.serverInfo = serverInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserAgent() {
|
||||||
|
return userAgent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserAgent(String userAgent) {
|
||||||
|
this.userAgent = userAgent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
package space.barrx.gwtdemo;
|
||||||
|
|
||||||
|
import com.google.gwt.user.client.rpc.RemoteService;
|
||||||
|
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The client side stub for the RPC service.
|
||||||
|
*/
|
||||||
|
@RemoteServiceRelativePath("greet")
|
||||||
|
public interface GreetingService extends RemoteService {
|
||||||
|
GreetingResponse greetServer(String name) throws IllegalArgumentException;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
package space.barrx.gwtdemo;
|
||||||
|
|
||||||
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The async counterpart of <code>GreetingService</code>.
|
||||||
|
*/
|
||||||
|
public interface GreetingServiceAsync {
|
||||||
|
void greetServer(String input, AsyncCallback<GreetingResponse> callback);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,104 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>space.barrx</groupId>
|
||||||
|
<artifactId>gwtdemo</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gwtproject</groupId>
|
||||||
|
<artifactId>gwt</artifactId>
|
||||||
|
<version>2.13.0</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.servlet</groupId>
|
||||||
|
<artifactId>jakarta.servlet-api</artifactId>
|
||||||
|
<version>6.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>net.ltgt.gwt.maven</groupId>
|
||||||
|
<artifactId>gwt-maven-plugin</artifactId>
|
||||||
|
<inherited>false</inherited>
|
||||||
|
<configuration>
|
||||||
|
<launcherDir>${basedir}/gwtdemo-server/target/gwt/launcherDir</launcherDir>
|
||||||
|
<!-- To be able to use gwt:devmode (useful on Windows where Ctrl+C won't kill gwt:codeserver)-->
|
||||||
|
<warDir>${basedir}/gwtdemo-server/target/gwt/launcherDir</warDir>
|
||||||
|
<devmodeArgs>
|
||||||
|
<arg>-noserver</arg>
|
||||||
|
</devmodeArgs>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
<pluginManagement>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.15.0</version>
|
||||||
|
<configuration>
|
||||||
|
<release>17</release>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-resources-plugin</artifactId>
|
||||||
|
<version>3.4.0</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>3.5.4</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-war-plugin</artifactId>
|
||||||
|
<version>3.5.1</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.eclipse.jetty.ee10</groupId>
|
||||||
|
<artifactId>jetty-ee10-maven-plugin</artifactId>
|
||||||
|
<version>12.1.6</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>net.ltgt.gwt.maven</groupId>
|
||||||
|
<artifactId>gwt-maven-plugin</artifactId>
|
||||||
|
<version>1.2.0</version>
|
||||||
|
<extensions>true</extensions>
|
||||||
|
<configuration>
|
||||||
|
<sourceLevel>17</sourceLevel>
|
||||||
|
<failOnError>true</failOnError>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
|
<version>3.4.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>attach-sources</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>jar-no-fork</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</pluginManagement>
|
||||||
|
</build>
|
||||||
|
<modules>
|
||||||
|
<module>gwtdemo-client</module>
|
||||||
|
<module>gwtdemo-shared</module>
|
||||||
|
<module>gwtdemo-server</module>
|
||||||
|
</modules>
|
||||||
|
</project>
|
||||||
Loading…
Reference in New Issue