Skip to content

Instantly share code, notes, and snippets.

@lofidewanto
lofidewanto / YourEntryPoint.java
Created March 20, 2018 08:50
GWT Boot - Better Implementation
package hello.client;
import com.google.gwt.core.client.*;
import com.google.gwt.user.client.ui.*;
@GwtModule(renameTo="basic")
public class YourEntryPoint implements EntryPoint {
@Override
public void onModuleLoad() {
Button button = new Button("Click me");
/**
* A composite of a TextBox and a CheckBox that optionally enables it.
*/
public class OptionalTextBox extends Composite implements
ClickHandler {
private TextBox textBox = new TextBox();
private CheckBox checkBox = new CheckBox();
/**
<!-- Apple class -->
<script language="javascript" type="text/javascript">
Apple = function () {
this.x = 40;
this.y = 2;
};
Apple.prototype.sum = function () {
return this.x + this.y;
};
...
...
Button button = new Button();
button.setType(..);
...
Element th1 = DOM.createTH();
th1.appendChild(button.getElement());
// NOT WORKING: add click event to Button
button.addClickHandler(event -> {
@lofidewanto
lofidewanto / pom.xml
Last active October 27, 2020 22:45
IndexedDB with Java Patterns - GWT Boot pom.xml
<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>
<!-- Using gwt-boot-starter-parent -->
<groupId>com.github.gwtboot</groupId>
<artifactId>gwt-boot-starter-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath />
@lofidewanto
lofidewanto / pom.xml
Last active October 25, 2020 14:24
IndexedDB with Java Patterns - GWT Boot pom.xml - Maven Plugin
...
<build>
<plugins>
<!-- GWT Maven Plugin -->
<plugin>
<groupId>net.ltgt.gwt.maven</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<configuration>
<moduleName>
com.github.lofi.Calculator
@lofidewanto
lofidewanto / AppEntryPoint.java
Last active October 27, 2020 22:30
IndexedDB with Java Patterns - Entry Point
package com.github.lofi.client
import java.util.logging.Logger;
import com.google.gwt.core.client.EntryPoint;
public class AppEntryPoint implements EntryPoint {
private static Logger logger = Logger.getLogger(AppEntryPoint.class.getName());
@Override
public void onModuleLoad() {
@lofidewanto
lofidewanto / comparison.csv
Last active October 25, 2020 16:30
IndexedDB with Java Patterns - Comparison Dagger2 and Spring Boot Annotations
Spring Boot Dagger2 Explanation
@Configuration @Module A class that provides or builds the objects' dependencies
@Bean @Provides Create the objects
@SpringBootApplication @Component Interface used to generate the injector for the entry point and serves as a bridge between dependency providers (@Module) and dependency users (@Inject)
@Component @Service @Singleton Marking the classes to be managed as Singleton by DI framework
@Scope @Singleton or nothing Scoping the objects
@Autowired @Inject Inject the object to the marked property or constructor
@lofidewanto
lofidewanto / ProductService.java
Last active October 25, 2020 20:07
IndexedDB with Java Patterns - Using Dagger2 - Consumer
package com.github.lofi.client;
import java.util.logging.Logger;
import javax.inject.Inject;
import javax.inject.Singleton;
@Singleton
public class ProductService {
private static Logger logger = Logger.getLogger(ProductService.class.getName());
private ProductIdbRepository productRepository;
@lofidewanto
lofidewanto / Repository.java
Created October 28, 2020 10:30
IndexedDB with Java Patterns - Repository.java
package com.github.lofi.client;
import java.util.Optional;
import java.util.Set;
interface Repository<T> {
Optional<T> get(String id);
Set<T> get();
void persist(T entity);
void remove(T entity);