This document discusses reducing JavaScript usage for backend developers by exploring web components, Polymer, and JavaServer Faces (JSF). It provides an overview of web components goals and standards, introduces Polymer and how it builds on web components, discusses JSF and the PrimeFaces component library, and demos how to use Polymer and PrimeFaces. The goals of web components, Polymer, and PrimeFaces are to reduce code, improve readability and reusability through composable elements. Browser support for the various web component specifications is outlined.
7. Goals:
● Build widgets
● …which can be reused reliably
● …and which won’t break pages if the next
version of the component changes
internal implementation details
9. 2008 - W3C start working on spec
...
2013 - Working draft is published
2014 - Polymer presentation on Google I/O
2015, May - Polymer 0.9 released
Timeline
10. Bower
● A package manager for the web
● Search for dependencies and install
them as packages
● Created by Twitter
● Open Source
www.bower.io
18. Polyfills
webcomponents.js is a set of polyfills built on
top of the Web Components specifications,
enable Web Components in browsers that lack
native support
It makes it possible for developers to use
these standards today
19. HTML Imports
Imports let include and reuse HTML docs in
other HTML docs.
for html <link rel="import" href="..">
We have <script src>, <link rel="stylesheet">,
<img>, <video>, <audio>...
20. HTML Imports
The URL is called an import location. To load content from
another domain, the import location needs to be CORS-enabled
21. HTML Imports: benefits
● Decomposition
● Combining several resources (JS,
CSS, ..) in one
● Reuse
29. Web Components
● Increase productivity
● Declarative
● Composability
● Implement APIs per element type
30. Polymer
Library built with some extra sugar, provides
a declarative syntax for defining custom
elements, special features including
● two-way data binding,
● declarative event handling,
● declarative inheritance
● property observation
32. Polymer elements
Core-elements are a set of visual and non-visual
utility elements for working with layout, user input,
selection, and scaffolding apps.
Polymer's paper collection implements
material design, highly visual, highly interactive
elements that include things like controls,
layouts, hero transitions, and scrolling effects.
36. ● Browser integrated: declarative event
handlers, mutation observers, query selector
● Interoperability - every framework is
compatible with DOM
Polymer : pros
● Write script in a scripting language, write
styles in a styling language, write markup in a
markup language.
● DevTools support
37. ● Browser support
● Not production ready, so far
● Client side technology - many similar
things to JS - frameworks, such
experience is very helpful
Polymer : cons
39. PrimeFaces
● Component library for JavaServer Faces
(JSF) based applications
● Standard part of the Java EE stack, so
you can’t do anything wrong
● The most popular JSF framework
45. PrimeFaces Selectors
An alternative, flexible, grouping based approach to
reference components to partially process and update.
update=”@(form)”
update=”@(form.first)”
update=”@(.mystyle)”
update=”@(.ui-datatable)”
update=”@(:input:not(select))”
update=”@(:input:disabled))”
47. Pros
● Mature and cross browser compatible
● Very large and helpful community
● Easy to understand even for novice team
members
48. and cons
● Tightly coupled: Layout, Design, Logic,
Communication with the server
● Need some time to make components
look right together
● Easy to make mistakes related to a
misunderstanding of the request-
response lifecycle
49. and cons
● Not suitable for heavily consumer oriented
website
● Final HTML page is generated from
pseudo-html (xhtml)
● and resulting HTML is often atrocious
● Generation take time
● JSF concept is outdated
50. Polymer vs PrimeFaces
● Future, based on modern
web technology
● Client side framework
● Requery strong knowledge in
JavaScript and CSS
● Specification is in progress
● Looks modern, easy build
single page application
● Past, part of Java EE
● Server side framework
Java based, but JavaScript,
CSS is very useful
● A lot of documentation,
books, strong community
● Looks more modest, but
has attractive paid theme
51. Polymer and PrimeFaces
● Powerful frameworks to simplify writing code for
the UI
● Contains set of ready components with styles
● Allow to create own components
● Keep page templating
● Have own search in DOM
● Encapsulate complexity
● Responsive Design
● Extendable
52. Polymer demo
1. Project skeleton (Spring-Boot, index.html)
2. Add Polymer, core-, paper-elements
3. Create component
4. - add data
5. - style
6. Style for welcome page
7. Add paper-input, paper-button and core-ajax
8. Backend service
53. PrimeFaces demo
1. Generate project skeleton from archetype (https:
//github.com/bprager/spring-boot-primefaces)
2. Welcome page layout
3. Add polymer components
4. Add interaction with Spring Been