Java Ee MVC and Polymer
Java Ee MVC and Polymer
Java Ee MVC and Polymer
• JCP Member
MVC
• New JSR (371) for Java EE 8
MVC
• In the last year, the community has added a couple of additional features (no official release)
1
Component-based frameworks (image from Ed Burns: Why Another MVC?)
MVC
• Built on top of JAX-RS
• Allows you to handle errors inside of Controllers instead of globally like JAX-RS
MVC
• Bring your own template engine!
2
• Support for encoding to avoid XSS attacks
◦ Visual Basic
◦ Delphi
◦ PowerBuilder
◦ WinForms
3
◦ Windows Presentaiton Framework
◦ ASP.NET
◦ Swing
◦ JavaFX
◦ JavaServer Faces
◦ Tapestry
◦ YUI
◦ KendoUI
◦ Bootstrap
◦ jQuery UI
◦ Wijmo
◦ PrimeUI
◦ Infragistics
4
We Work with Abstractions
• Programming model may be componentized, but native markup is not
5
<p:dataTable var="car" value="#{dtPaginatorView.cars}" rows="10"
paginator="true"
paginatorTemplate="{CurrentPageReport} {FirstPageLink}
{PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="5,10,15">
<p:column headerText="Id">
<h:outputText value="#{car.id}" />
</p:column>
<p:column headerText="Year">
<h:outputText value="#{car.year}" />
</p:column>
<p:column headerText="Brand">
<h:outputText value="#{car.brand}" />
</p:column>
<p:column headerText="Color">
<h:outputText value="#{car.color}" />
</p:column>
</p:dataTable>
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1"
data-toggle="dropdown" aria-expanded="true">
Dropdown
<span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Action</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Another
action</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Something else
here</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Separated
link</a></li>
</ul>
</div>
6
<div id="tabs">
<ul>
<li><a href="#tabs-1">Nunc tincidunt</a></li>
<li><a href="#tabs-2">Proin dolor</a></li>
<li><a href="#tabs-3">Aenean lacinia</a></li>
</ul>
<div id="tabs-1">
...
</div>
<div id="tabs-2">
...
</div>
<div id="tabs-3">
...
</div>
7
<paper-action-dialog backdrop autoCloseDisabled layered="false">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
• HTML Templates
• HTML Imports
• Shadow DOM
Demo
NOTE Show counter and source and inspect element in DOM
demo
• Shadow DOM and Custom Elements in development for Firefox and Safari
8
Closing the Browser Gap
polyfill
[pol-ee-fil]
noun
In web development, a polyfill (or polyfiller) is downloadable code which provides facilities that
are not built into a web browser. It implements technology that a developer expects the browser to
provide natively, providing a more uniform API landscape. For example, many features of HTML5
are not supported by versions of Internet Explorer older than version 8 or 9, but can be used by
web pages if those pages install a polyfill. Web shims and HTML5 Shivs are related concepts.
— Wikipedia
◦ Bosonic
◦ GE Predix UI
9
• Directory
◦ http://customelements.io
◦ simpla.io
• X-Tag
• Polymer
What is Poylmer?
Custom elements
Polymer library
Polymer
• Library for building web components
◦ Behaviors (mixins)
◦ Property observation
10
• Extensive set of tools
Polymer
• Developed by and used internally by Google
Polymer
<dom-module id="seed-element">
<template>
<style>
:host {
display: block;
box-sizing: border-box;
}
</style>
<content></content>
<p class="author">
<img src="{{author.image}}">
Cheers, {{author.name}}!
</p>
</template>
</dom-module>
<script>
Polymer({
is: 'seed-element',
properties: {
fancy: Boolean,
author: {
type: Object,
value: function() {
11
return {
name: 'Dimitri Glazkov',
image: 'http://addyosmani.com/blog/wp-
content/uploads/2013/04/unicorn.jpg',
};
}
},
},
// Element Lifecycle
ready: function() {
// `ready` is called after all elements have been configured, but
// propagates bottom-up. This element's children are ready, but parents
// are not.
},
attached: function() {
// `attached` fires once the element and its parents have been inserted
// into a document.
},
detached: function() {
// The analog to `attached`, `detached` fires when the element has been
// removed from a document.
},
// Element Behavior
sayHello: function(greeting) {
var response = greeting || 'Hello World!';
return 'seed-element says, ' + response;
}
});
</script>
12
Polymer Element Catalog
demo
• TodoApplication class
• login.jsp
NOTE
• LoginController - login-validation, including LoginForm
• todo.html
• mvc-tasks.xhtml
13
Questions?
• Slides and sample app: https://github.com/kito99/polymer-javaee-mvc-todo
• Webcomponents.org: http://webcomponents.org/
• Knowesis.info: http://knowesis.io/web/webcomponents
14