SlideShare a Scribd company logo
AUTO-GWT
Better GWT Programming with Xtend
Anton Kosyakov (@akosyakov), Sven Efftinge (@svenefftinge)

itemis
Java Interoperability
Low Signal-To-Noise Ratio
Powerful Concepts
Java Interoperability
• Familiar Syntax
• Compiles to readable Java source code
• Uses JDK (no own collection types)
• No messing with generics, primitives, nullable
• Integrates with Java Tools
Low Signal-To-Noise Ratio
• Type Inference
• property access
• good defaults
• sweet Lambdas
• optional parenthesis
• optional semicolons
Powerful Concepts
• Macros
• Extension Methods
• Enhanced Switch
• Template Expressions
• operator overloading
• Dispatch methods
Demo
Auto-GWT : Better GWT Programming with Xtend
clearCompletedButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
List<Todo> result = new ArrayList<Todo>();
for (Todo t : getTodos()) {
if (!t.isDone()) {
result.add(t);
}
}
setTodos(result);
}
});
Clearing Completed Tasks
clearCompletedButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
List<Todo> result = new ArrayList<Todo>();
for (Todo t : getTodos()) {
if (!t.isDone()) {
result.add(t);
}
}
setTodos(result);
}
});
clearCompletedButton.addClickHandler [
]
todos = todos.filter[!done].toList
Client Server Communication
public class TodoServiceImpl extends RemoteServiceServlet implements TodoService {
public List<Todo> load(final String name) {
return (List<Todo>) getMemcacheService().get(name);
}
public void save(final List<Todo> todos, final String name) {
getMemcacheService().put(name, todos);
}
}
@RemoteServiceRelativePath("todoService")
public interface TodoService extends RemoteService {
public List<Todo> load(final String name);
public void save(final List<Todo> todos, final String name);
}
public interface TodoServiceAsync {
public void load(final String name, final AsyncCallback<List<Todo>> result);
public void save(final List<Todo> todos, final String name, 

final AsyncCallback<Void> result);
}
1) Server-Side Service Implementation
2) Server-Side Service Interface
3) Client-Side Async-Interface
GWT-RPC in Java
1) Server-Side Service Implementation
GWT-RPC in Xtend
@GwtService
class TodoServiceImpl {
override List<Todo> load(String name) {
return memcacheService.get(name) as List<Todo>
}
override void save(List<Todo> todos, String name) {
memcacheService.put(name, todos)
}
}
@GwtService adds the needed boilerplate during compilation.
Building UIs Programmatically
with Xtend
FlowPanel view = new FlowPanel();
view.setStyleName("view");
...
Label label = new Label();
label.setText(todo.getText());
view.add(label);
Button button = new Button();
button.setStyleName("destroy");
view.add(button);
button.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
deleteTodo(todo);
}
});
Imperative UIs in Java
flowPanel [
styleName = 'view'
...
label [
text = todo.text
]
button [
styleName = 'destroy'
onClick [
deleteTodo(todo)
]
]
]
Declarative UIs in Xtend
That’s a so called Builder API
Declarative UI Design
using
<section id="todoapp">
<header id="header">
<h1>todos</h1>
<g:TextBox ui:field="todoText"/>
</header>
<section ui:field="mainSection">
<input ui:field="toggleAll" type="checkbox"></input>
<label for="toggle-all">Mark all as complete</label>
<ul id="todo-list">
<g:FlowPanel ui:field="todoPanel"></g:FlowPanel>
</ul>
</section>
<footer ui:field="todoStatsContainer">
<span id="todo-count">
<strong class="number" ui:field="remainingTodosCount"></strong>
<span class="word" ui:field="remainingTodosLabel"></span>
left.
</span>
<g:Button ui:field="clearCompleted">
Clear completed (<span class="number-done" ui:field="clearTodosCount"></span>)
</g:Button>
</footer>
</section>
The XML
public class ToDoView extends Composite {
interface ToDoViewUiBinder extends UiBinder<Widget,ToDoView> {
}
private static ToDoViewUiBinder uiBinder = 

GWT.create(ToDoViewUiBinder.class);
@UiField
protected SpanElement clearTodosCount;
@UiField
protected SpanElement remainingTodosLabel;
@UiField
protected FlowPanel todoPanel;
@UiField
protected InputElement toggleAll;
@UiField
protected Element remainingTodosCount;
@UiField
protected Button clearCompleted;
@UiField
protected TextBox todoText;
@UiField
protected Element mainSection;
@UiField
protected Element todoStatsContainer;
// ... actual implementation
}
Here’s the boilerplate!
Active Annotations Once More
@WithUiBinding
class ToDoView extends Composite {
// ... actual implementation
}
@WithUiBinding looks up the XML and 

adds the boilerplate for you.
Xtend - xtendlang.org
auto-gwt - auto-gwt.org
todomvc - github.com/DJCordhose/todomvc-xtend-gwt
Questions?

More Related Content

What's hot (20)

PDF
4Developers: Dominik Przybysz- Message Brokers
PROIDEA
 
DOCX
VPN Access Runbook
Taha Shakeel
 
PPTX
Config BuildConfig
NexThoughts Technologies
 
PDF
Node Boot Camp
Troy Miles
 
PDF
Testing Backbone applications with Jasmine
Leon van der Grient
 
PDF
Stubる - Mockingjayを使ったHTTPクライアントのテスト -
Kenji Tanaka
 
PDF
Jggug 2010 330 Grails 1.3 観察
Tsuyoshi Yamamoto
 
PDF
Talk KVO with rac by Philippe Converset
CocoaHeads France
 
PPTX
Javascript
Gita Kriz
 
PPT
Swiss army knife Spring
Mario Fusco
 
PDF
Selenium cheat sheet
Sri Priya P Kulkarni
 
PPTX
Rxjs marble-testing
Christoffer Noring
 
PDF
Clojure - A new Lisp
elliando dias
 
PDF
Anonymous functions in JavaScript
Mohammed Sazid Al Rashid
 
PDF
Rails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
Raimonds Simanovskis
 
PDF
Reactive Programming for a demanding world: building event-driven and respons...
Mario Fusco
 
PDF
Nativescript angular
Christoffer Noring
 
PDF
Introduction kot iin
Jedsada Tiwongvokul
 
PDF
Rails on Oracle 2011
Raimonds Simanovskis
 
4Developers: Dominik Przybysz- Message Brokers
PROIDEA
 
VPN Access Runbook
Taha Shakeel
 
Config BuildConfig
NexThoughts Technologies
 
Node Boot Camp
Troy Miles
 
Testing Backbone applications with Jasmine
Leon van der Grient
 
Stubる - Mockingjayを使ったHTTPクライアントのテスト -
Kenji Tanaka
 
Jggug 2010 330 Grails 1.3 観察
Tsuyoshi Yamamoto
 
Talk KVO with rac by Philippe Converset
CocoaHeads France
 
Javascript
Gita Kriz
 
Swiss army knife Spring
Mario Fusco
 
Selenium cheat sheet
Sri Priya P Kulkarni
 
Rxjs marble-testing
Christoffer Noring
 
Clojure - A new Lisp
elliando dias
 
Anonymous functions in JavaScript
Mohammed Sazid Al Rashid
 
Rails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
Raimonds Simanovskis
 
Reactive Programming for a demanding world: building event-driven and respons...
Mario Fusco
 
Nativescript angular
Christoffer Noring
 
Introduction kot iin
Jedsada Tiwongvokul
 
Rails on Oracle 2011
Raimonds Simanovskis
 

Similar to Auto-GWT : Better GWT Programming with Xtend (20)

PPTX
Ext GWT - Overview and Implementation Case Study
Avi Perez
 
PPT
Google Web Toolkits
Yiguang Hu
 
PPTX
Gwt session
Ahmed Akl
 
PPTX
Extending GWT
isurusndr
 
PPTX
Gwt session
Mans Jug
 
PDF
Javascript as a target language - GWT KickOff - Part 2/2
JooinK
 
PDF
Google Web Toolkitのすすめ
Kaisei Hamamoto
 
PPT
Google Web Toolkit Introduction - eXo Platform SEA
nerazz08
 
PPT
Gwt RPC
maheshm1206
 
PPTX
GWT = easy AJAX
Olivier Gérardin
 
PPT
Gwt and rpc use 2007 1
Sam Muhanguzi
 
PPT
Google Dev Day2007
lucclaes
 
PPTX
Google web toolkit ( Gwt )
Pankaj Bhasker
 
PDF
Google Web Toolkit (GWT)
Hacen Dadda
 
PPT
Google Web Toolkits
Yiguang Hu
 
PDF
Speed up your GWT coding with gQuery
Manuel Carrasco Moñino
 
PPT
GWT
yuvalb
 
PDF
JavaCro'15 - GWT integration with Vaadin - Peter Lehto
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
PDF
Gwt kickoff - Alberto Mancini & Francesca Tosi
firenze-gtug
 
PPT
GWT
Lorraine JUG
 
Ext GWT - Overview and Implementation Case Study
Avi Perez
 
Google Web Toolkits
Yiguang Hu
 
Gwt session
Ahmed Akl
 
Extending GWT
isurusndr
 
Gwt session
Mans Jug
 
Javascript as a target language - GWT KickOff - Part 2/2
JooinK
 
Google Web Toolkitのすすめ
Kaisei Hamamoto
 
Google Web Toolkit Introduction - eXo Platform SEA
nerazz08
 
Gwt RPC
maheshm1206
 
GWT = easy AJAX
Olivier Gérardin
 
Gwt and rpc use 2007 1
Sam Muhanguzi
 
Google Dev Day2007
lucclaes
 
Google web toolkit ( Gwt )
Pankaj Bhasker
 
Google Web Toolkit (GWT)
Hacen Dadda
 
Google Web Toolkits
Yiguang Hu
 
Speed up your GWT coding with gQuery
Manuel Carrasco Moñino
 
GWT
yuvalb
 
JavaCro'15 - GWT integration with Vaadin - Peter Lehto
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
Gwt kickoff - Alberto Mancini & Francesca Tosi
firenze-gtug
 
Ad

More from Sven Efftinge (20)

PDF
Parsing Expression With Xtext
Sven Efftinge
 
PDF
Language Engineering With Xtext
Sven Efftinge
 
PDF
Future of Xtext
Sven Efftinge
 
PDF
Functional programming with Xtend
Sven Efftinge
 
KEY
Domain Specific Languages (EclipseCon 2012)
Sven Efftinge
 
KEY
Xtend @ EclipseCon 2012
Sven Efftinge
 
KEY
Eclipse Xtend
Sven Efftinge
 
PDF
This Is Not Your Father's Java
Sven Efftinge
 
KEY
Getting the most out of Java [Nordic Coding-2010]
Sven Efftinge
 
PDF
Xtext at MDD Day 2010
Sven Efftinge
 
PDF
Dependency Injection for Eclipse developers
Sven Efftinge
 
PDF
Xtext Webinar
Sven Efftinge
 
KEY
Challenges In Dsl Design
Sven Efftinge
 
KEY
Code Generation in Agile Projects
Sven Efftinge
 
KEY
Xtext Eclipse Con
Sven Efftinge
 
KEY
Generic Editor
Sven Efftinge
 
PDF
Eclipse Banking Day
Sven Efftinge
 
PDF
Bessere Softwareentwicklung (Itemis Wintercon)
Sven Efftinge
 
PDF
Domain-Specific Languages in der Praxis
Sven Efftinge
 
PDF
Xtext @ Profict Summer Camp
Sven Efftinge
 
Parsing Expression With Xtext
Sven Efftinge
 
Language Engineering With Xtext
Sven Efftinge
 
Future of Xtext
Sven Efftinge
 
Functional programming with Xtend
Sven Efftinge
 
Domain Specific Languages (EclipseCon 2012)
Sven Efftinge
 
Xtend @ EclipseCon 2012
Sven Efftinge
 
Eclipse Xtend
Sven Efftinge
 
This Is Not Your Father's Java
Sven Efftinge
 
Getting the most out of Java [Nordic Coding-2010]
Sven Efftinge
 
Xtext at MDD Day 2010
Sven Efftinge
 
Dependency Injection for Eclipse developers
Sven Efftinge
 
Xtext Webinar
Sven Efftinge
 
Challenges In Dsl Design
Sven Efftinge
 
Code Generation in Agile Projects
Sven Efftinge
 
Xtext Eclipse Con
Sven Efftinge
 
Generic Editor
Sven Efftinge
 
Eclipse Banking Day
Sven Efftinge
 
Bessere Softwareentwicklung (Itemis Wintercon)
Sven Efftinge
 
Domain-Specific Languages in der Praxis
Sven Efftinge
 
Xtext @ Profict Summer Camp
Sven Efftinge
 
Ad

Recently uploaded (20)

PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
Advancing WebDriver BiDi support in WebKit
Igalia
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Advancing WebDriver BiDi support in WebKit
Igalia
 
Biography of Daniel Podor.pdf
Daniel Podor
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 

Auto-GWT : Better GWT Programming with Xtend

  • 1. AUTO-GWT Better GWT Programming with Xtend Anton Kosyakov (@akosyakov), Sven Efftinge (@svenefftinge)
 itemis
  • 3. Java Interoperability • Familiar Syntax • Compiles to readable Java source code • Uses JDK (no own collection types) • No messing with generics, primitives, nullable • Integrates with Java Tools
  • 4. Low Signal-To-Noise Ratio • Type Inference • property access • good defaults • sweet Lambdas • optional parenthesis • optional semicolons
  • 5. Powerful Concepts • Macros • Extension Methods • Enhanced Switch • Template Expressions • operator overloading • Dispatch methods
  • 8. clearCompletedButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { List<Todo> result = new ArrayList<Todo>(); for (Todo t : getTodos()) { if (!t.isDone()) { result.add(t); } } setTodos(result); } }); Clearing Completed Tasks
  • 9. clearCompletedButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { List<Todo> result = new ArrayList<Todo>(); for (Todo t : getTodos()) { if (!t.isDone()) { result.add(t); } } setTodos(result); } }); clearCompletedButton.addClickHandler [ ] todos = todos.filter[!done].toList
  • 11. public class TodoServiceImpl extends RemoteServiceServlet implements TodoService { public List<Todo> load(final String name) { return (List<Todo>) getMemcacheService().get(name); } public void save(final List<Todo> todos, final String name) { getMemcacheService().put(name, todos); } } @RemoteServiceRelativePath("todoService") public interface TodoService extends RemoteService { public List<Todo> load(final String name); public void save(final List<Todo> todos, final String name); } public interface TodoServiceAsync { public void load(final String name, final AsyncCallback<List<Todo>> result); public void save(final List<Todo> todos, final String name, 
 final AsyncCallback<Void> result); } 1) Server-Side Service Implementation 2) Server-Side Service Interface 3) Client-Side Async-Interface GWT-RPC in Java
  • 12. 1) Server-Side Service Implementation GWT-RPC in Xtend @GwtService class TodoServiceImpl { override List<Todo> load(String name) { return memcacheService.get(name) as List<Todo> } override void save(List<Todo> todos, String name) { memcacheService.put(name, todos) } } @GwtService adds the needed boilerplate during compilation.
  • 14. FlowPanel view = new FlowPanel(); view.setStyleName("view"); ... Label label = new Label(); label.setText(todo.getText()); view.add(label); Button button = new Button(); button.setStyleName("destroy"); view.add(button); button.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { deleteTodo(todo); } }); Imperative UIs in Java
  • 15. flowPanel [ styleName = 'view' ... label [ text = todo.text ] button [ styleName = 'destroy' onClick [ deleteTodo(todo) ] ] ] Declarative UIs in Xtend That’s a so called Builder API
  • 17. <section id="todoapp"> <header id="header"> <h1>todos</h1> <g:TextBox ui:field="todoText"/> </header> <section ui:field="mainSection"> <input ui:field="toggleAll" type="checkbox"></input> <label for="toggle-all">Mark all as complete</label> <ul id="todo-list"> <g:FlowPanel ui:field="todoPanel"></g:FlowPanel> </ul> </section> <footer ui:field="todoStatsContainer"> <span id="todo-count"> <strong class="number" ui:field="remainingTodosCount"></strong> <span class="word" ui:field="remainingTodosLabel"></span> left. </span> <g:Button ui:field="clearCompleted"> Clear completed (<span class="number-done" ui:field="clearTodosCount"></span>) </g:Button> </footer> </section> The XML
  • 18. public class ToDoView extends Composite { interface ToDoViewUiBinder extends UiBinder<Widget,ToDoView> { } private static ToDoViewUiBinder uiBinder = 
 GWT.create(ToDoViewUiBinder.class); @UiField protected SpanElement clearTodosCount; @UiField protected SpanElement remainingTodosLabel; @UiField protected FlowPanel todoPanel; @UiField protected InputElement toggleAll; @UiField protected Element remainingTodosCount; @UiField protected Button clearCompleted; @UiField protected TextBox todoText; @UiField protected Element mainSection; @UiField protected Element todoStatsContainer; // ... actual implementation } Here’s the boilerplate!
  • 19. Active Annotations Once More @WithUiBinding class ToDoView extends Composite { // ... actual implementation } @WithUiBinding looks up the XML and 
 adds the boilerplate for you.
  • 20. Xtend - xtendlang.org auto-gwt - auto-gwt.org todomvc - github.com/DJCordhose/todomvc-xtend-gwt Questions?