Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/gwtboot/gwt-boot-samples

GWT Boot: Samples to check all the Starters
https://github.com/gwtboot/gwt-boot-samples

boot framework gwt java javascript spring-boot starter

Last synced: about 1 month ago
JSON representation

GWT Boot: Samples to check all the Starters

Awesome Lists containing this project

README

        

# GWT Boot Samples

![Build Status](https://github.com/gwtboot/gwt-boot-samples/actions/workflows/maven.yml/badge.svg)

Here you can find some samples on how you can use the GWT Boot Starters in
your project. This quickstart document is based on following sample project: [gwt-boot-sample-basic](https://github.com/gwtboot/gwt-boot-samples/tree/master/gwt-boot-sample-basic).

Introduction article about GWT Boot Starters: [GWT Boot Starters — Bootstrap a Simple GWT Web App](https://bit.ly/GWTBootStartersFinal)

# IDE

You can use IntelliJ or Eclipse / STS. To be able to use Java APT correctly please take a look on how
to [configure Java APT with Maven](https://immutables.github.io/apt.html) in each development environment.

# Quick Start

## Step 1 - Create a Maven Project

Just create a simple Maven Project. Add the parent project and the
starter dependencies. To be able to compile to JavaScript you
need to add _gwt-maven-plugin_ and add your GWT module name.

```xml

com.github.gwtboot
gwt-boot-starter-parent
VERSION



com.github.gwtboot
gwt-boot-starter





net.ltgt.gwt.maven
gwt-maven-plugin

hello.YourModule

/basic/





```

**If you are using the SNAPSHOT version of the starter** you need to add Sonatype Snapshots repository by extending or creating `` section since the `gwtboot-modules` are not released yet, so the example needs to access the SNAPSHOT version of `gwtboot-modules`.

```xml


sonatype-snapshots
Sonatype Snapshots
https://oss.sonatype.org/content/repositories/snapshots

true
always
fail



```

## Step 2 - Create a GWT Module Descriptor _module.gwt.xml_

Create a GWT module descriptor at _src/main_ directory. In this file
you describe the _EntryPoint_ class which is similar to Java Main class
and method. Module rename-to="basic" means that the JavaScript will
be compiled to the script _basic.nocache.js_. This module inherits
everything from the Starter module. This JavaScript
can be imported in the host HTML file on the next step.

```xml


```

## Step 3 - Create a Host HTML File where your JavaScript can run

In this HTML file, located at _hello/public_, your generated JavaScript will run.
This JavaScript can access the HTML file. In this example the generated JavaScript
will access the div with _id="helloButton"_.

```html


Demo GWT Webapp

```

## Step 4 - Create your Java Entry Point _Main_ Class

The EntryPoint is the first class which will be executed.
In this example it will exchange the _"helloButton"_ with a
Button.

```java
package hello.client;

import com.google.gwt.core.client.*;
import com.google.gwt.user.client.ui.*;

public class YourEntryPoint implements EntryPoint {
@Override
public void onModuleLoad() {
Button button = new Button("Click me");
button.addClickHandler(clickEvent -> {
Window.alert("Hello World!");
});
RootPanel.get("helloButton").add(button);
}
}

```

In [gwt-boot-sample-basic](https://github.com/gwtboot/gwt-boot-samples/tree/master/gwt-boot-sample-basic)
you can take a look at the basic example in GWT.

Now you are ready to start your GWT basic sample app for the first time.

# Starting GWT in SuperDev Mode

The application _[gwt-boot-sample-basic](https://github.com/gwtboot/gwt-boot-samples/tree/master/gwt-boot-sample-basic)_
uses integrated Jetty server from GWT to deliver the HTML host file.
This can be done with other Servlet apps as well.

## Step 1 - Run GWT DevMode to automatically compile the code

First generate the GWT Module Descriptor and then run the GWT Dev Mode
in SuperDev mode to be able to compile the Java code to JavaScript code
on reload in the web browser. In Maven you can run following command:

```java
mvn gwt:generate-module gwt:devmode
```

You can just generate the module once and after that just run:

```java
mvn gwt:devmode
```

![GWT Development Mode](gwt-boot-sample-development-mode.png?raw=true "GWT Development Mode")

## Step 2 - Run the App in your Browser

Now you can copy&paste the "Copy to Clipboard" result of the GWT Development Mode UI above. Run it on:

```java
http://localhost:8888/basic
```

Just reload your web app and GWT SuperDev mode will transpile your
Java code to JavaScript on the fly. That's it, now you can develop
your web app with GWT incrementally and fast!

## Step 3 - Debug the App in your Browser

You can debug the Java code on the browser with the help of source maps. In this example we use Google Chrome.

![GWT Debug Chrome](gwt-boot-sample-debugging.png?raw=true "GWT Debug Chrome")

Enjoy!