SlideShare a Scribd company logo
1 of 24
Download to read offline
Web Components & GWT
Introducing GWT-Polymer
Manuel Carrasco Moñino.
GWT-meetup 2015
Provide a Java API to
consume Vaadin
Components in GWT
Motivation
Web Components:
State of the art
State of the Art
Native browser support
Polymer
Polymer makes it easier and faster to create
anything from a button to a complete
application across desktop, mobile, and
beyond.
● webcomponents.js
● polymer.js
● core-components
○ collapse
○ drawer
○ dropdown
○ field
○ header
○ icon
○ input
○ menu
○ range
○ splitter
○ toolbar
○ tooltip
Polymer Paper components
The Paper elements are a set of UI elements
that implement the material design spec
paper components
○ button
○ checkbox
○ dialog
○ elements
○ fab
○ focusable
○ icon
○ input
○ item
○ progress
○ radio
○ ripple
○ shadow
○ slider
○ tabs
○ toast
○ toggle
Vaadin Components
A collection of the awesome Vaadin widget
set.
vaadin components
○ grid
GWT & Web Components
1. Use JsInterop to wrap Js objects and export Java classes
a. @JsType Wrap JS Objects without writing JSNI
b. @JsExport Expose GWT classes and methods to JS (not used)
c. @JsFunction Use interfaces as JS Functions (some issues)
2. Hand write Java Interfaces for the Web API
a. Window, Document, Element, Style, Events, …
b. Implementation does not extend JSO, needs casting (issues)
c. They might come with Elemental-2.0
3. Code generation
a. There could be ways to create all the java boilerplate code
GWT JsInterop
1. Create reusable methods to import and create new
instances of web components
2. Define a Java Interface per component and event
- Extends HTMLElement or Event
3. Optionally Wrap each Interface in a Widget class for
classic GWT apps.
How to consume WC
Interfaces for native JS objects
@JsType
public interface HTMLElement extends Element {
}
@JsType
public interface Element extends Node {
@JsProperty
String getInnerHTML();
@JsProperty
DOMTokenList getClassList();
void setAttribute(String name, String value);
String getAttribute(String name);
void removeAttribute(String name);
}
@JsType
public interface Node extends EventTarget {
}
@JsType
public interface EventTarget {
void addEventListener(String type, EventListener listener);
}
Reusable methods
public class Polymer {
// Ensures that the tagName has been registered, otherwise injects
// the appropriate <import> tag in the document header
public static void ensureHTMLImport(String tagName) {
if ( !registered(tagName)) {
String href = GWT.getModuleBaseForStaticFiles() +
"bower_components/" + tagName + "/" + tagName + ".html";
Element link = Document.get().createLinkElement();
link.setAttribute("rel", "import");
link.setAttribute("href", href);
Document.get().getHead().appendChild(htmlImport);
}
}
// Returns a new instance of the Element. It loads the webcomponent
// if not loaded yet.
public static <T> T createElement(String tagName) {
ensureHTMLImport(tagName);
return (T)Document.get().createElement(tagName);
}
}
The WC Element interface
@JsType
public interface PaperButton extends HTMLElement {
@JsProperty PaperButton setLabel(String val);
@JsProperty String getLabel();
@JsProperty PaperButton setRaisedButton(boolean val);
@JsProperty boolean getRaisedButton();
@JsProperty PaperButton setIcon(String val);
@JsProperty String getIcon();
}
Consume WC in Java (Element API)
// Create a new instance of PaperButton
PaperButtonElement button = Polymer.create(PaperButtonElement.TAG;
// Set some properties
button.icon("polymer")
.label("Polymer")
.raisedButton(false);
// Add event listeners
button.addEventListener("click", new EventListener() {
public void onBrowserEvent(Event event) {
...
}
});
// Append to the document
myContainerElement.appendChild(button);
The WC Widget Class
public class PaperButton extends PolymerWidget {
//Default Constructor.
public PaperButton() {
this("");
}
//Constructor used by UIBinder
public PaperButton(String html) {
this(PaperButtonElement.TAG, html);
}
// Used when this element is extended by another.
protected PaperButton(String tag, String html) {
super(tag, html);
}
// Gets a handle to the Polymer object's underlying DOM element.
public PaperButtonElement getPolymerElement() {
return (PaperButtonElement) getElement();
}
public boolean isRaised() {
return getPolymerElement().isRaised();
}
}
public class PolymerWidget extends HTMLPanel {
public PolymerWidget(String tag, String html) {
super(tag, html);
Polymer.ensureHTMLImport(tag);
}
}
Consume WC in Java (Widget API)
// Widgets allow consume WC using the GWT classic way.
PaperButton button = new PaperButton();
button.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
// ...
}
});
RootPanel.get().add(button);
Consume WC in UIBinder
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:g='urn:import:com.google.gwt.user.client.ui'
xmlns:p='urn:import:com.vaadin.components.gwt.polymer.client.widget'>
<ui:style>
.container paper-button.colored {
background: #4285f4;
color: #fff;
}
</ui:style>
<g:HTMLPanel>
<p:PaperButton toggle="" raised="" active="" addStyleNames="{style.colored}">active</p:PaperButton>
<paper-button raised="" noink="">Click me</paper-button>
</g:HTMLPanel>
Introducing GWT-
Polymer
GWT-Polymer
1. It’s a code generator to produce GWT wrappers for
polymer elements
a. Scrapes source documentation
2. Uses standard JS libraries to parse components.
a. node.js, npm, bower, gulp
b. context-free parser + lodash.template
3. It’s a Vaadin Labs project
a. Just released a paper gwt API snapshot (using polymer 0.5)
b. Work in progress to support polymer 0.9 (hydrolysis parser)
c. Still under definition, expect package name changes, etc
GWT-Polymer workflow
1. Checkout git clone github.com/vaadin/gwt-polymer
2. Run npm install
3. Edit the bower.json file and add/remove the
components you need for your project.
4. Run bower install to download components
5. Run gulp gwt-api in order to generate all java files
6. Run mvn clean package to produce your package .jar
7. Everything is contained in the artefact (polyfill,
components, java code).
GWT-Polymer goals
1. Very little code to maintain.
a. 950 LOC / 108 KB
2. But it produces a lot of java code
a. 13400 LOC (paper & core elements)
3. It uses native JS parsers for JS code.
a. The same tools that polymer uses
b. No GWT generators nor APT processors.
4. Standard tools for web developers.
a. They can deliver gwt libraries without knowing java
Discussion
1. Should we deliver separated ready-to-use libraries?
a. GWT-Paper 0.5.6.x (matches paper version)
b. Vaadin-Components 0.5.0.x (matches vaadin version)
2. Should we support GWT Widgets or Elements?
3. Makes sense to use JS code generators, or should we
use the Java way?
4. Could we eventually support other JS parsers to wrap
other JS libraries?
a. closure annotations, typescript, etc.
Thanks
Links
- gwt-polymer project
- gwt-polymer-paper .jar artifact
- gwt-polymer-paper demo

More Related Content

What's hot

Gwt.Create Keynote San Francisco
Gwt.Create Keynote San FranciscoGwt.Create Keynote San Francisco
Gwt.Create Keynote San FranciscoRay Cromwell
 
Why and How to Use Virtual DOM
Why and How to Use Virtual DOMWhy and How to Use Virtual DOM
Why and How to Use Virtual DOMDaiwei Lu
 
The Complementarity of React and Web Components
The Complementarity of React and Web ComponentsThe Complementarity of React and Web Components
The Complementarity of React and Web ComponentsAndrew Rota
 
Vaadin Components @ Angular U
Vaadin Components @ Angular UVaadin Components @ Angular U
Vaadin Components @ Angular UJoonas Lehtinen
 
Using ReactJS in AngularJS
Using ReactJS in AngularJSUsing ReactJS in AngularJS
Using ReactJS in AngularJSBoris Dinkevich
 
Wicket Next (1.4/1.5)
Wicket Next (1.4/1.5)Wicket Next (1.4/1.5)
Wicket Next (1.4/1.5)jcompagner
 
How to Build ToDo App with Vue 3 + TypeScript
How to Build ToDo App with Vue 3 + TypeScriptHow to Build ToDo App with Vue 3 + TypeScript
How to Build ToDo App with Vue 3 + TypeScriptKaty Slemon
 
Introduction to VueJS & Vuex
Introduction to VueJS & VuexIntroduction to VueJS & Vuex
Introduction to VueJS & VuexBernd Alter
 
Building a Startup Stack with AngularJS
Building a Startup Stack with AngularJSBuilding a Startup Stack with AngularJS
Building a Startup Stack with AngularJSFITC
 
A Closer Look At React Native
A Closer Look At React NativeA Closer Look At React Native
A Closer Look At React NativeIan Wang
 
(Js) Export your own WebGL Viewer
(Js) Export your own WebGL Viewer(Js) Export your own WebGL Viewer
(Js) Export your own WebGL ViewerJooinK
 
Angular js vs. Facebook react
Angular js vs. Facebook reactAngular js vs. Facebook react
Angular js vs. Facebook reactKeyup
 
Polymer, A Web Component Polyfill Library
Polymer, A Web Component Polyfill LibraryPolymer, A Web Component Polyfill Library
Polymer, A Web Component Polyfill Librarynaohito maeda
 
Taking Your GWT App to Tablets with GXT 4.0
Taking Your GWT App to Tablets with GXT 4.0Taking Your GWT App to Tablets with GXT 4.0
Taking Your GWT App to Tablets with GXT 4.0David Chandler
 
Reactjs workshop
Reactjs workshop Reactjs workshop
Reactjs workshop Ahmed rebai
 

What's hot (20)

Gwt.Create Keynote San Francisco
Gwt.Create Keynote San FranciscoGwt.Create Keynote San Francisco
Gwt.Create Keynote San Francisco
 
Why and How to Use Virtual DOM
Why and How to Use Virtual DOMWhy and How to Use Virtual DOM
Why and How to Use Virtual DOM
 
The Complementarity of React and Web Components
The Complementarity of React and Web ComponentsThe Complementarity of React and Web Components
The Complementarity of React and Web Components
 
Vaadin Components @ Angular U
Vaadin Components @ Angular UVaadin Components @ Angular U
Vaadin Components @ Angular U
 
Using ReactJS in AngularJS
Using ReactJS in AngularJSUsing ReactJS in AngularJS
Using ReactJS in AngularJS
 
Web components
Web componentsWeb components
Web components
 
React
React React
React
 
Wicket Next (1.4/1.5)
Wicket Next (1.4/1.5)Wicket Next (1.4/1.5)
Wicket Next (1.4/1.5)
 
Vaadin & Web Components
Vaadin & Web ComponentsVaadin & Web Components
Vaadin & Web Components
 
How to Build ToDo App with Vue 3 + TypeScript
How to Build ToDo App with Vue 3 + TypeScriptHow to Build ToDo App with Vue 3 + TypeScript
How to Build ToDo App with Vue 3 + TypeScript
 
Introduction to VueJS & Vuex
Introduction to VueJS & VuexIntroduction to VueJS & Vuex
Introduction to VueJS & Vuex
 
Vaadin Components
Vaadin ComponentsVaadin Components
Vaadin Components
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
 
Building a Startup Stack with AngularJS
Building a Startup Stack with AngularJSBuilding a Startup Stack with AngularJS
Building a Startup Stack with AngularJS
 
A Closer Look At React Native
A Closer Look At React NativeA Closer Look At React Native
A Closer Look At React Native
 
(Js) Export your own WebGL Viewer
(Js) Export your own WebGL Viewer(Js) Export your own WebGL Viewer
(Js) Export your own WebGL Viewer
 
Angular js vs. Facebook react
Angular js vs. Facebook reactAngular js vs. Facebook react
Angular js vs. Facebook react
 
Polymer, A Web Component Polyfill Library
Polymer, A Web Component Polyfill LibraryPolymer, A Web Component Polyfill Library
Polymer, A Web Component Polyfill Library
 
Taking Your GWT App to Tablets with GXT 4.0
Taking Your GWT App to Tablets with GXT 4.0Taking Your GWT App to Tablets with GXT 4.0
Taking Your GWT App to Tablets with GXT 4.0
 
Reactjs workshop
Reactjs workshop Reactjs workshop
Reactjs workshop
 

Similar to Introducing GWT Polymer (vaadin)

Open social 2.0 sandbox ee and breaking out of the gadget box
Open social 2.0 sandbox  ee and breaking out of the gadget boxOpen social 2.0 sandbox  ee and breaking out of the gadget box
Open social 2.0 sandbox ee and breaking out of the gadget boxRyan Baxter
 
SoftShake 2013 - Vaadin componentization
SoftShake 2013 - Vaadin componentizationSoftShake 2013 - Vaadin componentization
SoftShake 2013 - Vaadin componentizationNicolas Fränkel
 
Angular JS2 Training Session #2
Angular JS2 Training Session #2Angular JS2 Training Session #2
Angular JS2 Training Session #2Paras Mendiratta
 
Java Web Programming on Google Cloud Platform [3/3] : Google Web Toolkit
Java Web Programming on Google Cloud Platform [3/3] : Google Web ToolkitJava Web Programming on Google Cloud Platform [3/3] : Google Web Toolkit
Java Web Programming on Google Cloud Platform [3/3] : Google Web ToolkitIMC Institute
 
Modern frontend development with VueJs
Modern frontend development with VueJsModern frontend development with VueJs
Modern frontend development with VueJsTudor Barbu
 
Introduction to Griffon
Introduction to GriffonIntroduction to Griffon
Introduction to GriffonJames Williams
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsJeff Durta
 
Asp.net By Durgesh Singh
Asp.net By Durgesh SinghAsp.net By Durgesh Singh
Asp.net By Durgesh Singhimdurgesh
 
Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web ToolkitsYiguang Hu
 
Architecting your GWT applications with GWT-Platform - Lesson 02
Architecting your GWT applications with GWT-Platform - Lesson 02Architecting your GWT applications with GWT-Platform - Lesson 02
Architecting your GWT applications with GWT-Platform - Lesson 02rhemsolutions
 
GWT Training - Session 2/3
GWT Training - Session 2/3GWT Training - Session 2/3
GWT Training - Session 2/3Faiz Bashir
 
Desbravando Web Components
Desbravando Web ComponentsDesbravando Web Components
Desbravando Web ComponentsMateus Ortiz
 
OGCE Project Overview
OGCE Project OverviewOGCE Project Overview
OGCE Project Overviewmarpierc
 
Wicket Introduction
Wicket IntroductionWicket Introduction
Wicket IntroductionEyal Golan
 
Web Components v1
Web Components v1Web Components v1
Web Components v1Mike Wilcox
 

Similar to Introducing GWT Polymer (vaadin) (20)

Open social 2.0 sandbox ee and breaking out of the gadget box
Open social 2.0 sandbox  ee and breaking out of the gadget boxOpen social 2.0 sandbox  ee and breaking out of the gadget box
Open social 2.0 sandbox ee and breaking out of the gadget box
 
SoftShake 2013 - Vaadin componentization
SoftShake 2013 - Vaadin componentizationSoftShake 2013 - Vaadin componentization
SoftShake 2013 - Vaadin componentization
 
Angular JS2 Training Session #2
Angular JS2 Training Session #2Angular JS2 Training Session #2
Angular JS2 Training Session #2
 
Java Web Programming on Google Cloud Platform [3/3] : Google Web Toolkit
Java Web Programming on Google Cloud Platform [3/3] : Google Web ToolkitJava Web Programming on Google Cloud Platform [3/3] : Google Web Toolkit
Java Web Programming on Google Cloud Platform [3/3] : Google Web Toolkit
 
Modern frontend development with VueJs
Modern frontend development with VueJsModern frontend development with VueJs
Modern frontend development with VueJs
 
Google Web Toolkit
Google Web ToolkitGoogle Web Toolkit
Google Web Toolkit
 
Introduction to Griffon
Introduction to GriffonIntroduction to Griffon
Introduction to Griffon
 
Os Johnson
Os JohnsonOs Johnson
Os Johnson
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
 
Asp.net By Durgesh Singh
Asp.net By Durgesh SinghAsp.net By Durgesh Singh
Asp.net By Durgesh Singh
 
Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web Toolkits
 
Architecting your GWT applications with GWT-Platform - Lesson 02
Architecting your GWT applications with GWT-Platform - Lesson 02Architecting your GWT applications with GWT-Platform - Lesson 02
Architecting your GWT applications with GWT-Platform - Lesson 02
 
GWT Training - Session 2/3
GWT Training - Session 2/3GWT Training - Session 2/3
GWT Training - Session 2/3
 
Desbravando Web Components
Desbravando Web ComponentsDesbravando Web Components
Desbravando Web Components
 
OGCE Project Overview
OGCE Project OverviewOGCE Project Overview
OGCE Project Overview
 
HTML5
HTML5HTML5
HTML5
 
Wicket Introduction
Wicket IntroductionWicket Introduction
Wicket Introduction
 
Dart Workshop
Dart WorkshopDart Workshop
Dart Workshop
 
Web Components v1
Web Components v1Web Components v1
Web Components v1
 
Angular2 + rxjs
Angular2 + rxjsAngular2 + rxjs
Angular2 + rxjs
 

More from Manuel Carrasco Moñino

Present and Future of GWT from a developer perspective
Present and Future of GWT from a developer perspectivePresent and Future of GWT from a developer perspective
Present and Future of GWT from a developer perspectiveManuel Carrasco Moñino
 
GwtQuery the perfect companion for GWT, GWT.create 2013
GwtQuery the perfect companion for GWT,  GWT.create 2013GwtQuery the perfect companion for GWT,  GWT.create 2013
GwtQuery the perfect companion for GWT, GWT.create 2013Manuel Carrasco Moñino
 
Rapid and Reliable Developing with HTML5 & GWT
Rapid and Reliable Developing with HTML5 & GWTRapid and Reliable Developing with HTML5 & GWT
Rapid and Reliable Developing with HTML5 & GWTManuel Carrasco Moñino
 
GWT: Why GWT, GQuery, and RequestFactory
GWT: Why GWT, GQuery, and RequestFactoryGWT: Why GWT, GQuery, and RequestFactory
GWT: Why GWT, GQuery, and RequestFactoryManuel Carrasco Moñino
 
Gwt seminario java_hispano_manolocarrasco
Gwt seminario java_hispano_manolocarrascoGwt seminario java_hispano_manolocarrasco
Gwt seminario java_hispano_manolocarrascoManuel Carrasco Moñino
 

More from Manuel Carrasco Moñino (20)

The Java alternative to Javascript
The Java alternative to JavascriptThe Java alternative to Javascript
The Java alternative to Javascript
 
GWT and PWA
GWT and PWAGWT and PWA
GWT and PWA
 
Present and Future of GWT from a developer perspective
Present and Future of GWT from a developer perspectivePresent and Future of GWT from a developer perspective
Present and Future of GWT from a developer perspective
 
GWT Contributor Workshop
GWT Contributor WorkshopGWT Contributor Workshop
GWT Contributor Workshop
 
CRUD with Polymer 2.0
CRUD with Polymer 2.0CRUD with Polymer 2.0
CRUD with Polymer 2.0
 
Web Components and PWA
Web Components and PWAWeb Components and PWA
Web Components and PWA
 
Building Components for Business Apps
Building Components for Business AppsBuilding Components for Business Apps
Building Components for Business Apps
 
Vaadin codemotion 2014
Vaadin codemotion 2014Vaadin codemotion 2014
Vaadin codemotion 2014
 
GwtQuery the perfect companion for GWT, GWT.create 2013
GwtQuery the perfect companion for GWT,  GWT.create 2013GwtQuery the perfect companion for GWT,  GWT.create 2013
GwtQuery the perfect companion for GWT, GWT.create 2013
 
Rapid and Reliable Developing with HTML5 & GWT
Rapid and Reliable Developing with HTML5 & GWTRapid and Reliable Developing with HTML5 & GWT
Rapid and Reliable Developing with HTML5 & GWT
 
Aprendiendo GWT
Aprendiendo GWTAprendiendo GWT
Aprendiendo GWT
 
Apache James/Hupa & GWT
Apache James/Hupa & GWTApache James/Hupa & GWT
Apache James/Hupa & GWT
 
GWT: Why GWT, GQuery, and RequestFactory
GWT: Why GWT, GQuery, and RequestFactoryGWT: Why GWT, GQuery, and RequestFactory
GWT: Why GWT, GQuery, and RequestFactory
 
Mod security
Mod securityMod security
Mod security
 
Gwt IV -mvp
Gwt IV -mvpGwt IV -mvp
Gwt IV -mvp
 
Gwt III - Avanzado
Gwt III - AvanzadoGwt III - Avanzado
Gwt III - Avanzado
 
Gwt II - trabajando con gwt
Gwt II - trabajando con gwtGwt II - trabajando con gwt
Gwt II - trabajando con gwt
 
Gwt I - entendiendo gwt
Gwt I - entendiendo gwtGwt I - entendiendo gwt
Gwt I - entendiendo gwt
 
Seguridad en redes de computadores
Seguridad en redes de computadoresSeguridad en redes de computadores
Seguridad en redes de computadores
 
Gwt seminario java_hispano_manolocarrasco
Gwt seminario java_hispano_manolocarrascoGwt seminario java_hispano_manolocarrasco
Gwt seminario java_hispano_manolocarrasco
 

Recently uploaded

BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfLivetecs LLC
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 

Recently uploaded (20)

BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdf
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 

Introducing GWT Polymer (vaadin)

  • 1. Web Components & GWT Introducing GWT-Polymer Manuel Carrasco Moñino. GWT-meetup 2015
  • 2. Provide a Java API to consume Vaadin Components in GWT Motivation
  • 6. Polymer Polymer makes it easier and faster to create anything from a button to a complete application across desktop, mobile, and beyond. ● webcomponents.js ● polymer.js ● core-components ○ collapse ○ drawer ○ dropdown ○ field ○ header ○ icon ○ input ○ menu ○ range ○ splitter ○ toolbar ○ tooltip
  • 7. Polymer Paper components The Paper elements are a set of UI elements that implement the material design spec paper components ○ button ○ checkbox ○ dialog ○ elements ○ fab ○ focusable ○ icon ○ input ○ item ○ progress ○ radio ○ ripple ○ shadow ○ slider ○ tabs ○ toast ○ toggle
  • 8. Vaadin Components A collection of the awesome Vaadin widget set. vaadin components ○ grid
  • 9. GWT & Web Components
  • 10. 1. Use JsInterop to wrap Js objects and export Java classes a. @JsType Wrap JS Objects without writing JSNI b. @JsExport Expose GWT classes and methods to JS (not used) c. @JsFunction Use interfaces as JS Functions (some issues) 2. Hand write Java Interfaces for the Web API a. Window, Document, Element, Style, Events, … b. Implementation does not extend JSO, needs casting (issues) c. They might come with Elemental-2.0 3. Code generation a. There could be ways to create all the java boilerplate code GWT JsInterop
  • 11. 1. Create reusable methods to import and create new instances of web components 2. Define a Java Interface per component and event - Extends HTMLElement or Event 3. Optionally Wrap each Interface in a Widget class for classic GWT apps. How to consume WC
  • 12. Interfaces for native JS objects @JsType public interface HTMLElement extends Element { } @JsType public interface Element extends Node { @JsProperty String getInnerHTML(); @JsProperty DOMTokenList getClassList(); void setAttribute(String name, String value); String getAttribute(String name); void removeAttribute(String name); } @JsType public interface Node extends EventTarget { } @JsType public interface EventTarget { void addEventListener(String type, EventListener listener); }
  • 13. Reusable methods public class Polymer { // Ensures that the tagName has been registered, otherwise injects // the appropriate <import> tag in the document header public static void ensureHTMLImport(String tagName) { if ( !registered(tagName)) { String href = GWT.getModuleBaseForStaticFiles() + "bower_components/" + tagName + "/" + tagName + ".html"; Element link = Document.get().createLinkElement(); link.setAttribute("rel", "import"); link.setAttribute("href", href); Document.get().getHead().appendChild(htmlImport); } } // Returns a new instance of the Element. It loads the webcomponent // if not loaded yet. public static <T> T createElement(String tagName) { ensureHTMLImport(tagName); return (T)Document.get().createElement(tagName); } }
  • 14. The WC Element interface @JsType public interface PaperButton extends HTMLElement { @JsProperty PaperButton setLabel(String val); @JsProperty String getLabel(); @JsProperty PaperButton setRaisedButton(boolean val); @JsProperty boolean getRaisedButton(); @JsProperty PaperButton setIcon(String val); @JsProperty String getIcon(); }
  • 15. Consume WC in Java (Element API) // Create a new instance of PaperButton PaperButtonElement button = Polymer.create(PaperButtonElement.TAG; // Set some properties button.icon("polymer") .label("Polymer") .raisedButton(false); // Add event listeners button.addEventListener("click", new EventListener() { public void onBrowserEvent(Event event) { ... } }); // Append to the document myContainerElement.appendChild(button);
  • 16. The WC Widget Class public class PaperButton extends PolymerWidget { //Default Constructor. public PaperButton() { this(""); } //Constructor used by UIBinder public PaperButton(String html) { this(PaperButtonElement.TAG, html); } // Used when this element is extended by another. protected PaperButton(String tag, String html) { super(tag, html); } // Gets a handle to the Polymer object's underlying DOM element. public PaperButtonElement getPolymerElement() { return (PaperButtonElement) getElement(); } public boolean isRaised() { return getPolymerElement().isRaised(); } } public class PolymerWidget extends HTMLPanel { public PolymerWidget(String tag, String html) { super(tag, html); Polymer.ensureHTMLImport(tag); } }
  • 17. Consume WC in Java (Widget API) // Widgets allow consume WC using the GWT classic way. PaperButton button = new PaperButton(); button.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { // ... } }); RootPanel.get().add(button);
  • 18. Consume WC in UIBinder <ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder' xmlns:g='urn:import:com.google.gwt.user.client.ui' xmlns:p='urn:import:com.vaadin.components.gwt.polymer.client.widget'> <ui:style> .container paper-button.colored { background: #4285f4; color: #fff; } </ui:style> <g:HTMLPanel> <p:PaperButton toggle="" raised="" active="" addStyleNames="{style.colored}">active</p:PaperButton> <paper-button raised="" noink="">Click me</paper-button> </g:HTMLPanel>
  • 20. GWT-Polymer 1. It’s a code generator to produce GWT wrappers for polymer elements a. Scrapes source documentation 2. Uses standard JS libraries to parse components. a. node.js, npm, bower, gulp b. context-free parser + lodash.template 3. It’s a Vaadin Labs project a. Just released a paper gwt API snapshot (using polymer 0.5) b. Work in progress to support polymer 0.9 (hydrolysis parser) c. Still under definition, expect package name changes, etc
  • 21. GWT-Polymer workflow 1. Checkout git clone github.com/vaadin/gwt-polymer 2. Run npm install 3. Edit the bower.json file and add/remove the components you need for your project. 4. Run bower install to download components 5. Run gulp gwt-api in order to generate all java files 6. Run mvn clean package to produce your package .jar 7. Everything is contained in the artefact (polyfill, components, java code).
  • 22. GWT-Polymer goals 1. Very little code to maintain. a. 950 LOC / 108 KB 2. But it produces a lot of java code a. 13400 LOC (paper & core elements) 3. It uses native JS parsers for JS code. a. The same tools that polymer uses b. No GWT generators nor APT processors. 4. Standard tools for web developers. a. They can deliver gwt libraries without knowing java
  • 23. Discussion 1. Should we deliver separated ready-to-use libraries? a. GWT-Paper 0.5.6.x (matches paper version) b. Vaadin-Components 0.5.0.x (matches vaadin version) 2. Should we support GWT Widgets or Elements? 3. Makes sense to use JS code generators, or should we use the Java way? 4. Could we eventually support other JS parsers to wrap other JS libraries? a. closure annotations, typescript, etc.
  • 24. Thanks Links - gwt-polymer project - gwt-polymer-paper .jar artifact - gwt-polymer-paper demo