6. Web Components
in Practice 1/2
A new TAG for your browser: ‘<my-ui-
component>’
Based on standard specifications
(no frameworks!)
7. Goodbye to browser plugins (WC + HTML5)
Isolated from other elements in DOM
Easy to share (npm, yarn)
Easy to integrate
Web Components
in Practice 2/2
23. W E B C O M P O N E N T S W I T H J A V A ( V A A D I N ) ?
25. Ser ver- s id e Java Comp one nt
@Tag("paper-slider")
public interface PaperSlider extends Element{
static PaperSlider create() {
return Elements.create(PaperSlider.class);
}
void setValue(double value);
@UpdatedBy(“value-change")
double getValue();
}
26. Clien t- s i de I mple me ntation
( i n t e n t i o n a l l y l e f t b l a n k )
27. Using a s er ver- s id e co mp one nt
PaperSlider paperSlider = PaperSlider.create();
paperSlider.setValue(50);
paperSlider.addEventListener("change", arguments->{
Notification.show(
"Value changed to"+paperSlider.getValue());
});
29. H O W T O C R E AT E YO U R
O W N W E B C O M P O N E N T ?
31. Polymer
J A V A S C R I P T L I B R A R Y F O R W E B C O M P O N E N T S
• Vaadin Core Elements are built with Polymer 2.0
• Mentally for Vaadin Developer Polymer is new GWT
• Developed by Google
• Helps building re-usable Web Components
• Utilises new emerging Web Component standards
• Polyfills missing features for browsers
32. Polyfills
M A K E S TA N D A R D S W O R K T O D A Y
• Implementations making older browsers support new standards
• Will eventually be out powered by Browser standards
33. ES6-Class definition
class Shape {
constructor (id, x, y) {
this.id = id
this.move(x, y)
}
move (x, y) {
this.x = x
this.y = y
}
}
34. ES6-Class Inheritance
class Rectangle extends Shape {
constructor (id, x, y, width, height) {
super(id, x, y)
this.width = width
this.height = height
}
}
class Circle extends Shape {
constructor (id, x, y, radius) {
super(id, x, y)
this.radius = radius
}
}
35. ES6-Static Members
class Rectangle extends Shape {
static defaultRectangle () {
return new Rectangle("default", 0, 0, 100, 100)
}
}
class Circle extends Shape {
static defaultCircle () {
return new Circle("default", 0, 0, 100)
}
}
var defRectangle = Rectangle.defaultRectangle();
var defCircle = Circle.defaultCircle();
36. ES6-Arrow Functions
odds = evens.map(v => v + 1)
pairs = evens.map(v => ({ even: v, odd: v + 1 }))
nums = evens.map((v, i) => v + i)
nums.forEach(v => {
if (v % 5 === 0)
fives.push(v)
})
48. Summary
• My talk has nothing to do with GWT :(
• Web components is the future of web
• Catch the train before it’s too late
• Vaadin provides pure client side web components as
Vaadin Elements
• Vaadin provides Java integration with Web
components
49. T H A N K YO U !
@haijian_wang
https://vaadin.com/blog/-/blogs/framework-roadmap-connecting-the-dots
https://vaadin.com/directory#!addon/elements-add-on