apache wicket: 10 jaar en verder - martijn dashorst

147
Apache Wicket 10 years and beyond Martijn Dashorst topicus onderwijs @dashorst APACHE WICKET

Upload: nljug

Post on 12-Jul-2015

216 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Apache Wicket: 10 jaar en verder - Martijn Dashorst

Apache Wicket10 years and beyond

Martijn Dashorsttopicus onderwijs @dashorst

APACHE WICKET

Page 2: Apache Wicket: 10 jaar en verder - Martijn Dashorst

a brief history of Wicket

the current stateof Wicket

the futureof Wicket

Page 3: Apache Wicket: 10 jaar en verder - Martijn Dashorst
Page 4: Apache Wicket: 10 jaar en verder - Martijn Dashorst

co-author

Page 5: Apache Wicket: 10 jaar en verder - Martijn Dashorst

10 year contributor to Wicket

Page 6: Apache Wicket: 10 jaar en verder - Martijn Dashorst

started in 2004 at topicuswithout any knowledge of web programming

Page 7: Apache Wicket: 10 jaar en verder - Martijn Dashorst

before Wicketat topicus

Page 8: Apache Wicket: 10 jaar en verder - Martijn Dashorst

2004

Page 9: Apache Wicket: 10 jaar en verder - Martijn Dashorst

using maverick velocity hibernate jasperreports

Page 10: Apache Wicket: 10 jaar en verder - Martijn Dashorst

lots of XML configuration

Page 11: Apache Wicket: 10 jaar en verder - Martijn Dashorst

1 change requires N files to be modified(for large values of N)

<command name="admin.tabelbeheer.edittoetsonderdeel"> <controller class="nl.topicus.bao.web.ctrl.lab.toetsen. <view name="success" path="/admin/tabelbeheer/toetsen/e <transform path="/mlayout/mainlayout.vm"> <param name="_pagetitle" value="Beheer Tabellen </transform> </view> <view name="error" path="/admin/tabelbeheer/toetsen/edi <transform path="/mlayout/mainlayout.vm"> <param name="_pagetitle" value="Beheer Tabellen </transform> </view> <view name="list" path="admin.tabelbeheer.edittoets.m" </command>

Page 12: Apache Wicket: 10 jaar en verder - Martijn Dashorst

high learning curve

Page 13: Apache Wicket: 10 jaar en verder - Martijn Dashorst

no back button support no multi-tab support

Page 14: Apache Wicket: 10 jaar en verder - Martijn Dashorst

HTTP Session dumping ground

Page 15: Apache Wicket: 10 jaar en verder - Martijn Dashorst

little to no reuse

</tr>#if($model.bean.absentieRegels.empty) <tr> <td colspan="19" class="border-r">#formname('groep.absent' </tr> #else#set($columnIndexes=[1,2,3,4,5,6,7,8,9,10])#foreach($row in $model.bean.absentieRegels) <tr> <td class="columnvalue">$arrayTool.elementAt($row, 0)</td #foreach($index in $columnIndexes) #set($melding=$arrayTool.elementAt($row, $index))

Page 16: Apache Wicket: 10 jaar en verder - Martijn Dashorst

complex UI neigh impossible

Page 17: Apache Wicket: 10 jaar en verder - Martijn Dashorst

a framework that makes reuse possible, minimises configuration, server side state management easy and is as type safe as possible

Page 18: Apache Wicket: 10 jaar en verder - Martijn Dashorst

Action Framework Anvil Apache Click Apache MyFaces Apache Shale Apache Sling Apache Struts Apache Struts 2 Apache Tapestry Apache Turbine Apache Wicket AppFuse Aranea Web Framework AribaWeb Aurora Baritus Barracuda Bento Bishop Brill Calyxo Cameleon Canyamo Caramba Cassandra Chiba Chrysalis Dinamica Dovetail DWR Echo Eclipse RAP Expresso fleXive Flower framework Folium FormEngine Genie Grails GWT Hamlets Helma Induction ItsNat Jacquard Jaffa Japple JAT JATO JBanana JBoss Seam Jeenius JFormular JOSSO JPublish JSPWidget Jspx-bay jStatemachine Jucas JVx JWAA JWarp jWic jZeno jZonic Macaw Makumba Maverick Melati Mentawai Millstone Nacho Niggle OpenEmcee OpenLaszlo OpenXava Oracle ADF OXF Pandora Playframework Pustefix Restlet RIFE Roma Meta Framework RSF Scope SerfJ Shocks Smile SOFIA Sombrero Spark Spring MVC Strecks Stripes Swinglets SwingWeb Tapestry TeaServlet ThinWire Trimpath Junction Turbine Vaadin Verge VRaptor Vroom Warfare Wavemaker WebObjects WebOnSwing WebWork wingS Xoplon Ze Framework ZK ztemplates

Page 19: Apache Wicket: 10 jaar en verder - Martijn Dashorst

120+ java web frameworks

Page 20: Apache Wicket: 10 jaar en verder - Martijn Dashorst

18 August 2004

Page 21: Apache Wicket: 10 jaar en verder - Martijn Dashorst

public class EditPage extends WebPage { private Person person; public EditPage(Person person) { this.person = person; add(new Button("save") { @Override public void onSubmit() { Entities.save(person); setResponsePage(new ShowPage(person)); } }); }}

Page 22: Apache Wicket: 10 jaar en verder - Martijn Dashorst

a framework that makes reuse possible, minimises configuration, server side state management easy and is as type safe as possible

✓ ✓

✓✓

Page 23: Apache Wicket: 10 jaar en verder - Martijn Dashorst

Action Framework Anvil Apache Click Apache MyFaces Apache Shale Apache Sling Apache Struts Apache Struts 2 Apache Tapestry Apache Turbine Apache Wicket AppFuse Aranea Web Framework AribaWeb Aurora Baritus Barracuda Bento Bishop Brill Calyxo Cameleon Canyamo Caramba Cassandra Chiba Chrysalis Dinamica Dovetail DWR Echo Eclipse RAP Expresso fleXive Flower framework Folium FormEngine Genie Grails GWT Hamlets Helma Induction ItsNat Jacquard Jaffa Japple JAT JATO JBanana JBoss Seam Jeenius JFormular JOSSO JPublish JSPWidget Jspx-bay jStatemachine Jucas JVx JWAA JWarp jWic jZeno jZonic Macaw Makumba Maverick Melati Mentawai Millstone Nacho Niggle OpenEmcee OpenLaszlo OpenXava Oracle ADF OXF Pandora Playframework Pustefix Restlet RIFE Roma Meta Framework RSF Scope SerfJ Shocks Smile SOFIA Sombrero Spark Spring MVC Strecks Stripes Swinglets SwingWeb Tapestry TeaServlet ThinWire Trimpath Junction Turbine Vaadin Verge VRaptor Vroom Warfare Wavemaker WebObjects WebOnSwing WebWork wingS Xoplon Ze Framework ZK ztemplates

Page 24: Apache Wicket: 10 jaar en verder - Martijn Dashorst

Action Framework Anvil Apache Click Apache MyFaces Apache Shale Apache Sling Apache Struts Apache Struts 2 Apache Tapestry Apache Turbine Apache Wicket AppFuse Aranea Web Framework AribaWeb Aurora Baritus Barracuda Bento Bishop Brill Calyxo Cameleon Canyamo Caramba Cassandra Chiba Chrysalis Dinamica Dovetail DWR Echo Eclipse RAP Expresso fleXive Flower framework Folium FormEngine Genie Grails GWT Hamlets Helma Induction ItsNat Jacquard Jaffa Japple JAT JATO JBanana JBoss Seam Jeenius JFormular JOSSO JPublish JSPWidget Jspx-bay jStatemachine Jucas JVx JWAA JWarp jWic jZeno jZonic Macaw Makumba Maverick Melati Mentawai Millstone Nacho Niggle OpenEmcee OpenLaszlo OpenXava Oracle ADF OXF Pandora Playframework Pustefix Restlet RIFE Roma Meta Framework RSF Scope SerfJ Shocks Smile SOFIA Sombrero Spark Spring MVC Strecks Stripes Swinglets SwingWeb Tapestry TeaServlet ThinWire Trimpath Junction Turbine Vaadin Verge VRaptor Vroom Warfare Wavemaker WebObjects WebOnSwing WebWork wingS Xoplon Ze Framework ZK ztemplates

Page 25: Apache Wicket: 10 jaar en verder - Martijn Dashorst

15 java web frameworks alivei.e. made any release in the last year

Page 26: Apache Wicket: 10 jaar en verder - Martijn Dashorst

including Wicket!

Page 27: Apache Wicket: 10 jaar en verder - Martijn Dashorst

What is Wicket?

Apache Wicket From Wikipedia, the free encyclopedia

Apache Wicket, commonly referred to as

Wicket, is a lightweight component-based web

application framework for the Java programming

language conceptually similar to JavaServer

Faces and Tapestry. It was originally written by

Jonathan Locke in April 2004. Version 1.0 was

released in June 2005. It graduated into an

Apache top-level project in June 2007.[2]

Page 28: Apache Wicket: 10 jaar en verder - Martijn Dashorst

A brief history of Wicket

Page 29: Apache Wicket: 10 jaar en verder - Martijn Dashorst

2004

Page 30: Apache Wicket: 10 jaar en verder - Martijn Dashorst

2004

The Server Side

Page 31: Apache Wicket: 10 jaar en verder - Martijn Dashorst

20052004

codehaus.org

The Server Side

Page 32: Apache Wicket: 10 jaar en verder - Martijn Dashorst

20052004

codehaus.org

The Server Side

Page 33: Apache Wicket: 10 jaar en verder - Martijn Dashorst

codehaus.org

2004

The Server Side JavaOne

1.0

1.1

2006

1.2

2005

AJAX

Page 34: Apache Wicket: 10 jaar en verder - Martijn Dashorst

2007

Page 35: Apache Wicket: 10 jaar en verder - Martijn Dashorst

2007

1.3

2008

Page 36: Apache Wicket: 10 jaar en verder - Martijn Dashorst

2007

1.3

2008 2009

1.4

2010 2011

1.5

Page 37: Apache Wicket: 10 jaar en verder - Martijn Dashorst

2007

1.3

2008 2009

1.4

2010 2011

1.5

Page 38: Apache Wicket: 10 jaar en verder - Martijn Dashorst

2012

6.0

2013 2014

6.12

6.2

6.4

6.6

6.8

6.10

6.1 6.5 6.96.11

6.13

7.0.0-M2

6.16

6.14

6.15 7.0.0-M1

6.3 6.76.17 7.0.0-M3

7.0.0-M4

6.18

Page 39: Apache Wicket: 10 jaar en verder - Martijn Dashorst

That's of Apache Wicket!

10 years

Page 40: Apache Wicket: 10 jaar en verder - Martijn Dashorst

The state of Wicket

Page 41: Apache Wicket: 10 jaar en verder - Martijn Dashorst

1. core

2. extensions

3. spring

4. datetime

5. auth-roles

Page 42: Apache Wicket: 10 jaar en verder - Martijn Dashorst

Mailinglist traffic

Page 43: Apache Wicket: 10 jaar en verder - Martijn Dashorst

Commit activity

Page 44: Apache Wicket: 10 jaar en verder - Martijn Dashorst

User Manual

195

25 Wicket Internals

25.1 Page storingDuring request handling, Wicket manages page instances through interface

. This interface creates a new page instance ororg.apache.wicket.request.handler.IPageProviderloads a previously serialized page instance if we provide the corrisponding page id. delegatesIPageProviderpage creation and retrieval to interface . When pageorg.apache.wicket.request.mapper.IPageSourceclass is provided delegates page creation to interface ,IPageSource org.apache.wicket.IPageFactorywhile when page id is provided it uses interface to load theorg.apache.wicket.page.IPageManagerpreviously serialized page.

The following workflow diagram summarizes the mechanism seen so far:

IPageManager

's task is to manage which pages have been used in a requestorg.apache.wicket.page.IPageManagerand store their last state in the backing stores, namely . The default implementation IPageStore

collects all stateful pages which have been used in theorg.apache.wicket.page.PageStoreManagerrequest cycle (more than one page can be used in a single request if for example or setResponsePage()

is used). At the end of the request all collected page instances are being storedRestartResponseExceptionin the first level cache - http session. They are stored in http session attribute named

and passed to the underlying "wicket:persistentPageManagerData-APPLICATION_NAME" IPageStore. When the next http request comes will ask for page with specific id and IPageProvider PageStoreManagerwill look first in the http session and if no match is found then it will delegate to the IPageStore. At the end of thesecond request the http session based cache is being overwritten completely with the newly used pageinstances.

To se tup ano ther imp lementa t ion use IPageManager. Theorg.apache.wicket.Application.setPageManagerProvider(IPageManagerProvider)

custom implementation may or may not use .IPageManager IPageStore/IDataStore

IPageStore

's role is to mediate the storing and loading of pages done byorg.apache.wicket.pageStore.IPageStorethe under ly ing . The defaul t implementat ion IDataStore

pre-processes the pages before passing them to org.apache.wicket.pageStore.DefaultPageStore

183

As you can see above, the Exception gets raised during the initialization of the instance evenWicketTesterbefore the actual test method gets executed. Even though we have applied rather cool and simple annotationbased test configuration already described and passed in perfectly well prepared ApplicationContext instance tothe WicketTester instance in the constructor, somewhere down the rabbit hole someone complained that noWebApplicationContext instance could have been found which seems to be required in order to initialize theWicketTester properly.

The problem that we run against here is due to the fact that SpringComponentInjector during its own initializationis trying to get hold of an according Spring's ApplicationContext instance that would normally be there in aruntime environment but does not find any since we are running in a test environment currently.SpringComponentInjector delegates to Spring's own WebApplicationContextUtils class to retrieve the instance ofApplicationContext out of the ServletContext which is perfectly fine for a runtime environment but is unfortunatelyfailing in a test environment:

public WebApplicationContext getRequiredWebApplicationContext(ServletContext sc)static IllegalStateException {throws

WebApplicationContext wac = getWebApplicationContext(sc); (wac == ) {if null IllegalStateException(throw new "No WebApplicationContext found: no

);ContextLoaderListener registered?" } wac;return}

If you still remember we defined a ContextLoaderListener in our web.xml file as part of the configuration of ourruntime environment that makes sure an according WebApplicationContext instance gets initialized andregistered against the ServletContext properly. Luckily, this problem can easily be solved if we slightly changethe way we initialize SpringComponentInjector in our main MyWebApplication class. Apart from the constructorthat we have used so far, there is another constructor in the SpringComponentInjector class that expects thecaller to provide it with an according ApplicationContext instance rather than trying to resolve one on its own:

public SpringComponentInjector(WebApplication webapp, ApplicationContext ctx, wrapInProxies)boolean{ (webapp == )if null { IllegalArgumentException( );throw new "Argument [[webapp]] cannot be "null }

(ctx == )if null { IllegalArgumentException( );throw new "Argument [[ctx]] cannot be "null }

// store context in application's metadata … webapp.setMetaData(CONTEXT_KEY, ApplicationContextHolder(ctx));new

// … and create and register the annotation aware injector InjectorHolder.setInjector( AnnotSpringInjector( ContextLocator(),new new

Page 45: Apache Wicket: 10 jaar en verder - Martijn Dashorst

In a Nutshell, Wicket...

… has had 18,255 commits made by 62 contributors representing 318,037 lines of code

… is mostly written in Java witha well-commented source code

… has a well established, mature codebase maintained by a large development team with stable Y-O-Y commits

… took an estimated 84 years of effort (COCOMO model) starting with its first commit in September, 2004ending with its most recent commit 1 days ago– openhub.net report for Wicket

Page 46: Apache Wicket: 10 jaar en verder - Martijn Dashorst
Page 47: Apache Wicket: 10 jaar en verder - Martijn Dashorst
Page 48: Apache Wicket: 10 jaar en verder - Martijn Dashorst
Page 49: Apache Wicket: 10 jaar en verder - Martijn Dashorst
Page 50: Apache Wicket: 10 jaar en verder - Martijn Dashorst

The future of Wicket

Page 51: Apache Wicket: 10 jaar en verder - Martijn Dashorst

Wicket 1.4security releases only

Page 52: Apache Wicket: 10 jaar en verder - Martijn Dashorst

Wicket 1.5security releases only

Page 53: Apache Wicket: 10 jaar en verder - Martijn Dashorst

Wicket 6

Page 54: Apache Wicket: 10 jaar en verder - Martijn Dashorst

java 6

Page 55: Apache Wicket: 10 jaar en verder - Martijn Dashorst

semantic versioning

Page 56: Apache Wicket: 10 jaar en verder - Martijn Dashorst

semi-monthly releases mainly bug fixes some new minor features

Page 57: Apache Wicket: 10 jaar en verder - Martijn Dashorst

Wicket 7

Page 58: Apache Wicket: 10 jaar en verder - Martijn Dashorst

Java 7

Page 59: Apache Wicket: 10 jaar en verder - Martijn Dashorst

Servlet 3

Page 60: Apache Wicket: 10 jaar en verder - Martijn Dashorst

Minor API breaks

Page 61: Apache Wicket: 10 jaar en verder - Martijn Dashorst

Component queuing

Page 62: Apache Wicket: 10 jaar en verder - Martijn Dashorst

public class HomePage extends WebPage {

public HomePage() {

add(new Label("title", "Hello!"));

} }

Page 63: Apache Wicket: 10 jaar en verder - Martijn Dashorst

public class HomePage extends WebPage {

public HomePage() {

add(new Label("title", "Hello!"));

} } <html>

<body> <h1 wicket:id="title"></h1> </body> </html>

Page 64: Apache Wicket: 10 jaar en verder - Martijn Dashorst

public class HomePage extends WebPage {

public HomePage() {

add(new Label("title", "Hello!"));

} } <html>

<body> <h1 wicket:id="title"></h1> </body> </html>

Page 65: Apache Wicket: 10 jaar en verder - Martijn Dashorst

Add a <div> around content...

Page 66: Apache Wicket: 10 jaar en verder - Martijn Dashorst

<html> <body> <div wicket:id="container">

<h1 wicket:id="title"></h1>

</div> </body> </html>

Page 67: Apache Wicket: 10 jaar en verder - Martijn Dashorst

<html> <body> <div wicket:id="container">

<h1 wicket:id="title"></h1>

</div> </body> </html>

public class HomePage extends WebPage { public HomePage() { add(new WebMarkupContainer("container")); add(new Label("title", "Hello!")); } }

Page 68: Apache Wicket: 10 jaar en verder - Martijn Dashorst

<html> <body> <div wicket:id="container">

<h1 wicket:id="title"></h1>

</div> </body> </html>

public class HomePage extends WebPage { public HomePage() { add(new WebMarkupContainer("container")); add(new Label("title", "Hello!")); } }

Page 69: Apache Wicket: 10 jaar en verder - Martijn Dashorst

code always follows markupin Wicket

Page 70: Apache Wicket: 10 jaar en verder - Martijn Dashorst

<html> <body> <div wicket:id="container"> <h1 wicket:id="title"></h1> </div> </body> </html>

Page 71: Apache Wicket: 10 jaar en verder - Martijn Dashorst

public class HomePage extends WebPage { public HomePage() { WebMarkupContainer container = new WebMarkupContainer("container"); add(container); add(new Label("title", "Hello!")); } }

<html> <body> <div wicket:id="container"> <h1 wicket:id="title"></h1> </div> </body> </html>

Page 72: Apache Wicket: 10 jaar en verder - Martijn Dashorst

public class HomePage extends WebPage { public HomePage() { WebMarkupContainer container = new WebMarkupContainer("container"); add(container); add(new Label("title", "Hello!")); } }

<html> <body> <div wicket:id="container"> <h1 wicket:id="title"></h1> </div> </body> </html>

Page 73: Apache Wicket: 10 jaar en verder - Martijn Dashorst

public class HomePage extends WebPage { public HomePage() { WebMarkupContainer container = new WebMarkupContainer("container"); add(container); container.add(new Label("title", "Hello!")); } }

<html> <body> <div wicket:id="container"> <h1 wicket:id="title"></h1> </div> </body> </html>

Page 74: Apache Wicket: 10 jaar en verder - Martijn Dashorst

code always follows markupin Wicket

or does it?

Page 75: Apache Wicket: 10 jaar en verder - Martijn Dashorst

Enter Component Queuing(coming to you in wicket 7)

Page 76: Apache Wicket: 10 jaar en verder - Martijn Dashorst

What if we delay adding components?

Queue components until their location in the markup hierarchy is know

markupContainer.add(new Label(...)); markupContainer.queue(new Label(...));

Page 77: Apache Wicket: 10 jaar en verder - Martijn Dashorst

public class HomePage extends WebPage { public HomePage() { WebMarkupContainer container = new WebMarkupContainer("container"); add(container); container.add(new Label("title", "Hello!")); }}

public class HomePage extends WebPage { public HomePage() { queue(new WebMarkupContainer("container")); queue(new Label("title", "Hello!")); }}

Page 78: Apache Wicket: 10 jaar en verder - Martijn Dashorst

<html> <body> <header><h1 wicket:id="title"></h1></header> <div wicket:id="container"> ... </div> </body> </html>

<html> <body> <div wicket:id="container"> <h1 wicket:id="title"></h1> </div> </body> </html>

Page 79: Apache Wicket: 10 jaar en verder - Martijn Dashorst

Limitations ofComponent Queuing

Page 80: Apache Wicket: 10 jaar en verder - Martijn Dashorst

queue(new Label("label", "Some text"));queue(new Label("label", "Other text"));

Page 81: Apache Wicket: 10 jaar en verder - Martijn Dashorst

queue(new Label("label", "Some text"));queue(new Label("label", "Other text"));

Page 82: Apache Wicket: 10 jaar en verder - Martijn Dashorst

queue(new Label("first"));queue(new Label("last"));WebMarkupContainer secure=new WebMarkupContainer("secure") { public void onConfigure() { super.onConfigure(); setVisible(isViewingOwnProfile()); }}; queue(secure);secure.queue(new Label("creditCardNumber"));secure.queue(new Label("creditCardExpiry"));

Restrictions of Queuing: Ancestors

Page 83: Apache Wicket: 10 jaar en verder - Martijn Dashorst

<h3> Welcome, <span wicket:id="first"></span> <span wicket:id="last"></span>!</h3><fieldset wicket:id="secure"> <legend>Secure</legend> <dt>Card expiry: <i wicket:id="creditCardExpiry"> <dt>Card number: <i wicket:id="creditCardNumber"></fieldset>

Page 84: Apache Wicket: 10 jaar en verder - Martijn Dashorst

<h3> Welcome, <span wicket:id="first"></span> <span wicket:id="last"></span>!</h3><fieldset wicket:id="secure"> <legend>Secure</legend> <dt>Card expiry: <i wicket:id="creditCardExpiry"> <dt>Card number: <i wicket:id="creditCardNumber"></fieldset>

Page 85: Apache Wicket: 10 jaar en verder - Martijn Dashorst

<h3> Welcome, <span wicket:id="first"></span> <span wicket:id="last"></span>!</h3><fieldset wicket:id="secure"> <legend>Secure</legend> <dt>Card expiry: <i wicket:id="creditCardExpiry"></fieldset> <dt>Card number: <i wicket:id="creditCardNumber">

Page 86: Apache Wicket: 10 jaar en verder - Martijn Dashorst

<h3> Welcome, <span wicket:id="first"></span> <span wicket:id="last"></span>!</h3><fieldset wicket:id="secure"> <legend>Secure</legend> <dt>Card expiry: <i wicket:id="creditCardExpiry"></fieldset> <dt>Card number: <i wicket:id="creditCardNumber">

Page 87: Apache Wicket: 10 jaar en verder - Martijn Dashorst

<fieldset wicket:id="secure"> <h3> Welcome, <span wicket:id="first"></span> <span wicket:id="last"></span>! </h3> <legend>Secure</legend> <dt>Card expiry: <i wicket:id="creditCardExpiry"> <dt>Card number: <i wicket:id="creditCardNumber"></fieldset>

Page 88: Apache Wicket: 10 jaar en verder - Martijn Dashorst

<fieldset wicket:id="secure"> <h3> Welcome, <span wicket:id="first"></span> <span wicket:id="last"></span>! </h3> <legend>Secure</legend> <dt>Card expiry: <i wicket:id="creditCardExpiry"> <dt>Card number: <i wicket:id="creditCardNumber"></fieldset>

Page 89: Apache Wicket: 10 jaar en verder - Martijn Dashorst

Component Queuing

• Wicket 7 feature

• Prefer queue() when markup hierarchy can be altered

• Uniqueness of Wicket IDs still requirement at same level of queuing

• Can move down into child markup hierarchy

• Can't move up the markup hierarchy

Page 90: Apache Wicket: 10 jaar en verder - Martijn Dashorst

Wicket 8

Page 91: Apache Wicket: 10 jaar en verder - Martijn Dashorst

Java 8

Page 92: Apache Wicket: 10 jaar en verder - Martijn Dashorst

PROJECT LAMBDA “functional” programming in Java

Page 93: Apache Wicket: 10 jaar en verder - Martijn Dashorst

public interface ILinkListener { void onLickClicked();}

ILinkListener l = new ILinkListener(){ @Override public void onLinkClicked() { System.out.println("Klik"); }}

Page 94: Apache Wicket: 10 jaar en verder - Martijn Dashorst

public interface ILinkListener { void onLickClicked();}

ILinkListener l = () -> { System.out.println("Klik"); }

Page 95: Apache Wicket: 10 jaar en verder - Martijn Dashorst

ILinkListener l = () -> { System.out.println("Klik"); }

ILinkListener l = new ILinkListener(){ @Override public void onLinkClicked() { System.out.println("Klik"); }}

or

Page 96: Apache Wicket: 10 jaar en verder - Martijn Dashorst

add(new Link<Void>("save") { @Override public void onClick() { dao.save(object); getSession().info("Saved."); setResponsePage(new OtherPage()) }});

Page 97: Apache Wicket: 10 jaar en verder - Martijn Dashorst

add(new Link<Void>("save") { @Override public void onClick() { dao.save(object); getSession().info("Saved."); setResponsePage(new OtherPage()) }});

Page 98: Apache Wicket: 10 jaar en verder - Martijn Dashorst

add(new Link<>("save").onClick(()-> { dao.save(object); getSession().info("Saved."); setResponsePage(new OtherPage())});

no more type information

Page 99: Apache Wicket: 10 jaar en verder - Martijn Dashorst

private void onSave() { dao.save(object); getSession().info("Saved."); setResponsePage(new OtherPage())}

Page 100: Apache Wicket: 10 jaar en verder - Martijn Dashorst

private void onSave() { dao.save(object); getSession().info("Saved."); setResponsePage(new OtherPage())}

add(new Link<Void>("save") .onClick(this::onSave));

Page 101: Apache Wicket: 10 jaar en verder - Martijn Dashorst

A link with onclick, visibility and body

Page 102: Apache Wicket: 10 jaar en verder - Martijn Dashorst

add(new Link<Void>("like"));

Page 103: Apache Wicket: 10 jaar en verder - Martijn Dashorst

add(new Link<Void>("like") {});

Page 104: Apache Wicket: 10 jaar en verder - Martijn Dashorst

add(new Link<Void>("like") { @Override public void onClick() { person.likedBy(me); }});

Page 105: Apache Wicket: 10 jaar en verder - Martijn Dashorst

add(new Link<Void>("like") { @Override public void onClick() { person.likedBy(me); } @Override public boolean isVisible() { return person.isNotLiked(); }});

Page 106: Apache Wicket: 10 jaar en verder - Martijn Dashorst

add(new Link<Void>("like") { @Override public void onClick() { person.likedBy(me); } @Override public boolean isVisible() { return person.isNotLiked(); }}.setBody());

Page 107: Apache Wicket: 10 jaar en verder - Martijn Dashorst

add(new Link<Void>("like") { @Override public void onClick() { person.likedBy(me); } @Override public boolean isVisible() { return person.isNotLiked(); }}.setBody(new AbstractReadOnlyModel<String>() { }));

Page 108: Apache Wicket: 10 jaar en verder - Martijn Dashorst

add(new Link<Void>("like") { @Override public void onClick() { person.likedBy(me); } @Override public boolean isVisible() { return person.isNotLiked(); }}.setBody(new AbstractReadOnlyModel<String>() { @Override public String getObject() { } }));

Page 109: Apache Wicket: 10 jaar en verder - Martijn Dashorst

add(new Link<Void>("like") { @Override public void onClick() { person.likedBy(me); } @Override public boolean isVisible() { return person.isNotLiked(); }}.setBody(new AbstractReadOnlyModel<String>() { @Override public String getObject() { StringBuilder sb = new StringBuilder("Like "); sb.append(person.getFirstName()); return sb.toString(); } }));

Page 110: Apache Wicket: 10 jaar en verder - Martijn Dashorst

A link with onclick, visibility and body

Page 111: Apache Wicket: 10 jaar en verder - Martijn Dashorst

add(new Link<>("like"));

Page 112: Apache Wicket: 10 jaar en verder - Martijn Dashorst

add(new Link<>("like") );

Page 113: Apache Wicket: 10 jaar en verder - Martijn Dashorst

add(new Link<>("like") .visible(() -> person.isNotLiked()));

Page 114: Apache Wicket: 10 jaar en verder - Martijn Dashorst

add(new Link<>("like") .visible(() -> person.isNotLiked()) .onClick(() -> person.likedBy(me)));

Page 115: Apache Wicket: 10 jaar en verder - Martijn Dashorst

add(new Link<>("like") .visible(() -> person.isNotLiked()) .onClick(() -> person.likedBy(me)) .body(() -> { }));

Page 116: Apache Wicket: 10 jaar en verder - Martijn Dashorst

add(new Link<>("like") .visible(() -> person.isNotLiked()) .onClick(() -> person.likedBy(me)) .body(() -> { StringBuilder sb = new StringBuilder("Like "); sb.append(person.getFirstName()); return sb.toString(); }));

Page 117: Apache Wicket: 10 jaar en verder - Martijn Dashorst

add(new Link<>("like") .visible(() -> person.isNotLiked()) .onClick(() -> person.likedBy(me)) .body(() -> { StringBuilder sb = new StringBuilder("Like "); sb.append(person.getFirstName()); return sb.toString(); }));

add(new Link<Void>("like") { @Override public void onClick() { person.likedBy(me); } @Override public boolean isVisible() { return person.isNotLiked(); }}.setBody(new AbstractReadOnlyModel<String>() { @Override public String getObject() { StringBuilder sb = new StringBuilder("Like "); sb.append(person.getFirstName()); return sb.toString(); } }));

Anon inner classes: 17 lines Java 8 lambdas: 9 lines

Page 118: Apache Wicket: 10 jaar en verder - Martijn Dashorst

nashorn

Page 119: Apache Wicket: 10 jaar en verder - Martijn Dashorst

JavaScript validation

Page 120: Apache Wicket: 10 jaar en verder - Martijn Dashorst

ScriptEngineManager m = new ScriptEngineManager();

ScriptEngine nashorn = m.getEngineByName("nashorn");

nashorn.put("age", validatable.getValue()); String js = "age >= 18";

try { Object result = nashorn.eval(js); if(!((Boolean)result) { ValidationError e = new ValidationError(); validatable.error(e); } } catch(Exception e) { }

Page 121: Apache Wicket: 10 jaar en verder - Martijn Dashorst

ScriptEngineManager m = new ScriptEngineManager();

ScriptEngine nashorn = m.getEngineByName("nashorn");

nashorn.put("age", validatable.getValue()); String js = "age >= 18";

try { Object result = nashorn.eval(js); if(!((Boolean)result) { ValidationError e = new ValidationError(); validatable.error(e); } } catch(Exception e) { }

Page 122: Apache Wicket: 10 jaar en verder - Martijn Dashorst

ScriptEngineManager m = new ScriptEngineManager();

ScriptEngine nashorn = m.getEngineByName("nashorn");

nashorn.put("age", validatable.getValue()); String js = "age >= 18";

try { Object result = nashorn.eval(js); if(!((Boolean)result) { ValidationError e = new ValidationError(); validatable.error(e); } } catch(Exception e) { }

Page 123: Apache Wicket: 10 jaar en verder - Martijn Dashorst

ScriptEngineManager m = new ScriptEngineManager();

ScriptEngine nashorn = m.getEngineByName("nashorn");

nashorn.put("age", validatable.getValue()); String js = "age >= 18";

try { Object result = nashorn.eval(js); if(!((Boolean)result) { ValidationError e = new ValidationError(); validatable.error(e); } } catch(Exception e) { }

Page 124: Apache Wicket: 10 jaar en verder - Martijn Dashorst

ScriptEngineManager m = new ScriptEngineManager();

ScriptEngine nashorn = m.getEngineByName("nashorn");

nashorn.put("age", validatable.getValue()); String js = "age >= 18";

Object result = nashorn.eval(js); try { if(!((Boolean)result) { ValidationError e = new ValidationError(); validatable.error(e); } } catch(Exception e) { }

Page 125: Apache Wicket: 10 jaar en verder - Martijn Dashorst

ScriptEngineManager m = new ScriptEngineManager();

ScriptEngine nashorn = m.getEngineByName("nashorn");

nashorn.put("age", validatable.getValue()); String js = "age >= 18";

Object result = nashorn.eval(js); if(!((Boolean)result) { ValidationError e = new ValidationError(); validatable.error(e); } try { } catch(Exception e) { }

Page 126: Apache Wicket: 10 jaar en verder - Martijn Dashorst

ScriptEngineManager m = new ScriptEngineManager();

ScriptEngine nashorn = m.getEngineByName("nashorn");

nashorn.put("age", validatable.getValue()); String js = "age >= 18";

try { Object result = nashorn.eval(js); if(!((Boolean)result) { ValidationError e = new ValidationError(); validatable.error(e); } } catch (Exception e) { }

Page 127: Apache Wicket: 10 jaar en verder - Martijn Dashorst

java.time

Page 128: Apache Wicket: 10 jaar en verder - Martijn Dashorst

Roadmap

Page 129: Apache Wicket: 10 jaar en verder - Martijn Dashorst

Monthly releases

Page 130: Apache Wicket: 10 jaar en verder - Martijn Dashorst

6.14 6.15

7.0-M17.0-M2

7.0-M4

6.18

feb mar nov

2014

7.0-RC

6.19

jan

Page 131: Apache Wicket: 10 jaar en verder - Martijn Dashorst

7.0? 7.1?

8.0-M1?

7.5?

feb mar may

2015

8.0-M2?

7.6?

jun

Page 132: Apache Wicket: 10 jaar en verder - Martijn Dashorst

Is there a future for server-side frameworks?

Page 133: Apache Wicket: 10 jaar en verder - Martijn Dashorst
Page 134: Apache Wicket: 10 jaar en verder - Martijn Dashorst

“We continue to see teams run into trouble using JSF -- JavaServer Faces -- and are recommending you avoid this technology.”

–ThoughtWorks Technology Radar January 2014

Page 135: Apache Wicket: 10 jaar en verder - Martijn Dashorst

“We continue to see teams run into trouble using JSF -- JavaServer Faces -- and are recommending you avoid this technology. Teams seem to choose JSF because it is a J2EE standard without really evaluating whether the programming model suits them. We think JSF is flawed because it tries to abstract away HTML, CSS and HTTP, exactly the reverse of what modern web frameworks do. JSF, like ASP.NET webforms, attempts to create statefulness on top of the stateless protocol HTTP and ends up causing a whole host of problems involving shared server-side state. We are aware of the improvements in JSF 2.0, but think the model is fundamentally broken. We recommend teams use simple frameworks and embrace and understand web technologies including HTTP, HTML and CSS.”–ThoughtWorks Technology Radar January 2014

Page 136: Apache Wicket: 10 jaar en verder - Martijn Dashorst

“We continue to see teams run into trouble using JSF and are recommending you avoid this technology. We think JSF is flawed because it tries to abstract away HTML, CSS and HTTP. JSF, like ASP.NET webforms, attempts to create statefulness on top of the stateless protocol HTTP. We think the model is fundamentally broken.”

–ThoughtWorks Technology Radar January 2014

Page 137: Apache Wicket: 10 jaar en verder - Martijn Dashorst

“We continue to see teams run into trouble using JSF and are recommending you avoid this technology. We think JSF is flawed because it tries to abstract away HTML, CSS and HTTP. JSF, like ASP.NET webforms, attempts to create statefulness on top of the stateless protocol HTTP. We think the model is fundamentally broken.”

–ThoughtWorks Technology Radar January 2014

Page 138: Apache Wicket: 10 jaar en verder - Martijn Dashorst

“We recommend teams use simple frameworks and embrace and understand web technologies

including HTTP, HTML and CSS.”

Page 139: Apache Wicket: 10 jaar en verder - Martijn Dashorst

JavaScript Frameworks War

JQuery AngularJS Ember.js React

Backbone.js Meteor KnockoutJS Dojo

Agility.js CanJS Polymer Mithril

Maria Flight Knockback.jsAmpersand

Page 140: Apache Wicket: 10 jaar en verder - Martijn Dashorst

What is the Future for web development?

Page 141: Apache Wicket: 10 jaar en verder - Martijn Dashorst

What is the Future for web development?

Web Components

Page 142: Apache Wicket: 10 jaar en verder - Martijn Dashorst

What is the Future for web development?

Web Components

PolymerAngularJS(2.0)

Page 143: Apache Wicket: 10 jaar en verder - Martijn Dashorst

What is the Future of Wicket?

Page 144: Apache Wicket: 10 jaar en verder - Martijn Dashorst

a brief history of Wicket

the current stateof Wicket

the futureof Wicket

Summary

Page 145: Apache Wicket: 10 jaar en verder - Martijn Dashorst

Thank you!

Page 146: Apache Wicket: 10 jaar en verder - Martijn Dashorst

Questions?

Page 147: Apache Wicket: 10 jaar en verder - Martijn Dashorst

contact @dashorst

topicus stand