SlideShare a Scribd company logo
Web Components
@joonaslehtinen
Founder & CEO





for Java Developers
Component based UI?
Web Components 101
Integration strategies
Component
Oriented UI?
Web Components for Java Developers
Benefits

Composition
Separation
Reusability
Rich component
oriented UI in Java?
Swing

Java FX
Statically typed Java
UI Components
Applets
RPC
Stateless
JSF
XML + Java
UI Components
Multi page rendering
Glue Ajax on top
Stateful
GWT
Statically typed Java
RPC
UI Components
Stateless
Compiles to JavaScript
Vaadin
ZK
Single-page rendering
Automatic communications
Statically typed Java
Stateful
UI Components
Problem solved
for Java developers?
Web Java>>
Web
Components
101
<x-gangnam-style>
</x-gangnam-style>
Everything
is an element
DOM is the
Framework
Web Components for Java Developers
<my-component></my-component>
Custom Elements
document.registerElement(
'my-component',
{
prototype: proto
}
);
Custom Elements
var proto =
Object.create(HTMLElement.prototype);
proto.createdCallback = function() {
var div = document.createElement('div');
div.textContent = 'My Custom Element';
this.appendChild(div);
};
Custom Elements
Custom Elements
Shadow DOM
Shadow DOM
Document
<my-component> (shadow host)
Shadow border
<div>
"This is Shadow DOM"
Shadow DOM
var host = document.querySelector('#host');
var root = host.createShadowRoot();
var div = document.createElement('div');
div.textContent = 'This is Shadow DOM';
root.appendChild(div);
Shadow DOM
var proto =
Object.create(HTMLElement.prototype);
proto.createdCallback = function() {
var root = this.createShadowRoot();
root.textContent = 'My Custom Element';
};
Shadow DOM
Shadow DOM
Document (light DOM)
<my-component> (shadow host)
Shadow border
<div> (shadow DOM)
Content border
<div> (light DOM)
Shadow DOM Dictionary
Local DOM = DOM created and managed by custom element
Shadow DOM = native way of implementing Light DOM
Light DOM = "Normal" DOM that is written to page ("view source")
Shady DOM = Local DOM imply in normal DOM by Polymer
Shadow DOM
Document (light DOM)
<my-component> (host)
Shadow border
<div> (shadow/local)
Content border
<div> (light DOM)
<div> (local DOM)
Content border
<div> (light
DOM)
<template id="tmp">
<style>
...
</style>
<div>
<h1>Web Components</h1>
<img src="logo.svg">
</div>
</template>
Templates
var tmp = document.querySelector('#tmp');
var clone = document.importNode(tmp.content, true);
var host = document.querySelector('#host');
host.appendChild(clone);
Templates
HTML Imports
"import com.mybusiness.MyComponent;"
but for HTML5
index.html
<link rel="import"
href="my-component.html">
my-component.html
<link rel="stylesheet"
href="css/style.css">
<script src="js/script.js">
HTML Imports
Browser
Support?
:-?
Blink
:-)
Everything pretty much works
Firefox
:-|
Mozilla is committed in bringing full
support, but not all of it is there yet
WebKit
:-|
Shadow DOM landed on the trunk last week, but
Apple is keeping mouth shut on its plans
Edge
:-|
Microsoft started working on it and is committed
to releasing a full support eventually
IE
:-(
Guaranteed to never add support
Custom Element
HTML Template
Shadow DOM
HTML Import
CHROME OPERA FIREFOX SAFARI IE
Browser support
Polyfills
:-]
Trying to emulate it on all "modern browsers"
https://github.com/webcomponents/webcomponentsjs
*Indicates the current version of the browser, ~Indicates support may be flaky. If using Custom Elements or HTML
Imports with Shadow DOM, you will get the non-flaky Mutation Observer polyfill that Shadow DOM includes.
Polyfill: webcomponents.js support
Web Components for Java Developers
Polymer
<my-counter counter="10">Points</my-counter>
Increase
Points
Value: 10
<dom-module id="my-counter">
<template>
<style> /*...*/ </style>
<div id="label"><content></content></div>
Value: <span id="counterVal">{{counter}}</span><br>
<button on-tap="{{increment}}">Increment</button>
</template>
<script> … </script>
</dom-module>
Polymer({
is: 'my-counter',

properties: {
counter: {
type: Integer,
value: 0, // Default value
}
counterChanged: function() {
this.$.counterVal.classList.add('highlight');
},
increment: function() { this.counter++; }
});
Web Components for Java Developers
https://www.polymer-project.org/1.0/
Web Components
in Java apps?
1) REST API in Java
2) Wrap with GWT
3) Bind to server-side Java
1) REST API in Java
2) Wrap with GWT
3) Bind to server-side Java
Spring
Vaadin
Elements
Web Components
library that seamlessly
extends Polymer with
focus on building
business apps
<vaadin-grid>
Render static HTML in a JSP?
<vaadin-grid>
<table>
<colgroup>
<col header-text="Name">
<col header-text="Value">
<col header-text="Progress">
</colgroup>
<tbody>
<tr>
<td>Project A</td><td>10000</td><td>0.8</td>
</tr>
...
Lose
benefits
with a slow
multi-page app
Setup columns
Web Components for Java Developers
Configure grid and bind to REST API
function PagedDataSource()
< 160 lines of Ajax, paging, caching,
sorting and other logic >
Render a column with progressbar
Build REST API (finally some Java )
:-)
Spring is magical…
Build REST API
https://github.com/vaadin-
marcus/vaadin-grid-rest
1) REST API in Java
2) Wrap with GWT
3) Bind to server-side Java
Web Components for Java Developers
Vaadin
GWT
Polymer
Elements
GWT API generated
for Polymer Paper
and Iron elements
https://github.com/vaadin/
gwt-polymer-elements
Source
Bootstrap GWT application
UI Binder Support
Widget Java Class
http://www.gwtproject.org/doc/latest/
polymer-tutorial/create.html
Step-by-step tutorial
https://github.com/vaadin/gwt-api-generator
Vaadin GWT API Generator
my-component.html MyComponent.java
1) REST API in Java
2) Wrap with GWT
3) Bind to server-side Java
Framework
UI in Server-side Java
• Initial HTML
• CSS (theme)
• Images
• JavaScript
1.2M total

307k
compress
135k
reduced
widgetset
Web Components for Java Developers
• name=”Joonas”
• button clicked
261 bytes

Web Components for Java Developers
• name=”Joonas”
• button clicked
261 bytes

• Add notification
267 bytes

Connecting web components
Option 1: AbstractJavaScriptComponent
Option 2: Server-side Elements Add-on
Option 3: Vaadin 8, eventually :)
Connecting web components
Option 1: AbstractJavaScriptComponent
Option 2: Server-side Elements Add-on
Option 3: Vaadin 8, eventually :)
UI in Server-side Java
PaperButton.java
Communication
Construction
Event API
Web Components for Java Developers
Recommendations
For Java developers
Keep using Java
based component
oriented frameworks
you use today.
Wrap web components
to your current
framework 1-by-1, but
only when needed.
Consider going all-in
when your target
browsers and Java
framework support web
components natively.
@joonaslehtinen
Founder & CEO
slides
slideshare.com/joonaslehtinen
Hiring to
Vaadin Berlin

More Related Content

PDF
Speed up your GWT coding with gQuery
PPTX
Web Components the best marriage for a PWA
PDF
Introducing GWT Polymer (vaadin)
PDF
Rock GWT UI's with Polymer Elements
PDF
Vaadin Components @ Angular U
PDF
Intro to Web Components, Polymer & Vaadin Elements
PDF
GQuery a jQuery clone for Gwt, RivieraDev 2011
PDF
Booting up with polymer
Speed up your GWT coding with gQuery
Web Components the best marriage for a PWA
Introducing GWT Polymer (vaadin)
Rock GWT UI's with Polymer Elements
Vaadin Components @ Angular U
Intro to Web Components, Polymer & Vaadin Elements
GQuery a jQuery clone for Gwt, RivieraDev 2011
Booting up with polymer

What's hot (20)

PDF
Vaadin Components
PDF
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
PDF
Vaadin & Web Components
PDF
Vaadin Introduction, 7.3 edition
ODP
Wicket Next (1.4/1.5)
PDF
Introduction to Vaadin
KEY
Wicket 2010
PDF
Building a Secure App with Google Polymer and Java / Spring
PDF
[FEConf Korea 2017]Angular 컴포넌트 대화법
PDF
Apache Wicket Web Framework
PPT
Google Web Toolkits
PDF
Vaadin 7.2
PDF
Polymer, A Web Component Polyfill Library
PDF
Magento Product Types Demystified
PDF
Booting up with polymer
PDF
The Complementarity of React and Web Components
PDF
Modern Web Application Development Workflow - EclipseCon Europe 2014
PDF
Vaadin Flow - JavaLand 2018
PDF
Vaadin 8 and 10
PPTX
Polymer / WebComponents
Vaadin Components
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Vaadin & Web Components
Vaadin Introduction, 7.3 edition
Wicket Next (1.4/1.5)
Introduction to Vaadin
Wicket 2010
Building a Secure App with Google Polymer and Java / Spring
[FEConf Korea 2017]Angular 컴포넌트 대화법
Apache Wicket Web Framework
Google Web Toolkits
Vaadin 7.2
Polymer, A Web Component Polyfill Library
Magento Product Types Demystified
Booting up with polymer
The Complementarity of React and Web Components
Modern Web Application Development Workflow - EclipseCon Europe 2014
Vaadin Flow - JavaLand 2018
Vaadin 8 and 10
Polymer / WebComponents
Ad

Similar to Web Components for Java Developers (20)

PPTX
Google Polymer Introduction
PDF
Web components - An Introduction
PPTX
Checkout Customizations in Magento 2 - MageTitansMCR 2017
PPTX
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
PPTX
Orchard Harvest 2014 - The Future of Widgets?
PDF
A brave new web - A talk about Web Components
PPTX
Developing New Widgets for your Views in Owl
PDF
Polymer
PPTX
Knockout.js
PDF
Server side rendering with React and Symfony
PDF
Angular - Chapter 4 - Data and Event Handling
PDF
HTML5 New and Improved
PPTX
Web Components: back to the future
PPTX
Magic of web components
PPTX
Developing Next-Gen Enterprise Web Application
PDF
Knockoutjs databinding
PDF
Web Components v1
KEY
PHPConf-TW 2012 # Twig
PPTX
AngularJs Workshop SDP December 28th 2014
PPTX
Academy PRO: React JS
Google Polymer Introduction
Web components - An Introduction
Checkout Customizations in Magento 2 - MageTitansMCR 2017
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
Orchard Harvest 2014 - The Future of Widgets?
A brave new web - A talk about Web Components
Developing New Widgets for your Views in Owl
Polymer
Knockout.js
Server side rendering with React and Symfony
Angular - Chapter 4 - Data and Event Handling
HTML5 New and Improved
Web Components: back to the future
Magic of web components
Developing Next-Gen Enterprise Web Application
Knockoutjs databinding
Web Components v1
PHPConf-TW 2012 # Twig
AngularJs Workshop SDP December 28th 2014
Academy PRO: React JS
Ad

More from Joonas Lehtinen (20)

PDF
Hybrid webinar
PDF
Vaadin intro
PDF
Vaadin intro at GWT.create conference
PDF
Hybrid applications
PDF
Notes on architecture
PDF
Vaadin roadmap-devoxx-2013
PDF
Beoynd Vaadin 7
PDF
Vaadin 7
PDF
PDF
Hackathon - Building vaadin add on components
PDF
PDF
Vaadin today and tomorrow
PDF
Migration from vaadin 6 to vaadin 7 devoxx france 2013
PDF
Vaadin7 modern-web-apps-in-java
PDF
Vaadin 7 Today and Tomorrow
PDF
Vaadin 7
PDF
Desingning reusable web components
PDF
Lecture: Vaadin Overview
PDF
Vaadin 7
PDF
Vaadin 7 what next
Hybrid webinar
Vaadin intro
Vaadin intro at GWT.create conference
Hybrid applications
Notes on architecture
Vaadin roadmap-devoxx-2013
Beoynd Vaadin 7
Vaadin 7
Hackathon - Building vaadin add on components
Vaadin today and tomorrow
Migration from vaadin 6 to vaadin 7 devoxx france 2013
Vaadin7 modern-web-apps-in-java
Vaadin 7 Today and Tomorrow
Vaadin 7
Desingning reusable web components
Lecture: Vaadin Overview
Vaadin 7
Vaadin 7 what next

Recently uploaded (20)

PPTX
Introduction to Artificial Intelligence
PPTX
ISO 45001 Occupational Health and Safety Management System
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
history of c programming in notes for students .pptx
PPTX
L1 - Introduction to python Backend.pptx
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
medical staffing services at VALiNTRY
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
AI in Product Development-omnex systems
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
top salesforce developer skills in 2025.pdf
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
Introduction to Artificial Intelligence
ISO 45001 Occupational Health and Safety Management System
Navsoft: AI-Powered Business Solutions & Custom Software Development
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
How to Migrate SBCGlobal Email to Yahoo Easily
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Design an Analysis of Algorithms I-SECS-1021-03
history of c programming in notes for students .pptx
L1 - Introduction to python Backend.pptx
Adobe Illustrator 28.6 Crack My Vision of Vector Design
medical staffing services at VALiNTRY
Odoo POS Development Services by CandidRoot Solutions
How Creative Agencies Leverage Project Management Software.pdf
AI in Product Development-omnex systems
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Odoo Companies in India – Driving Business Transformation.pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
top salesforce developer skills in 2025.pdf
ManageIQ - Sprint 268 Review - Slide Deck

Web Components for Java Developers