Choosing a JWF - Javaone 2011

download Choosing a JWF - Javaone 2011

of 50

Transcript of Choosing a JWF - Javaone 2011

  • 8/3/2019 Choosing a JWF - Javaone 2011

    1/50

    Choosing a Java Based

    Web Framework:A Comparison

    Richard Pack

    Salesforce.com

    TS-21280

  • 8/3/2019 Choosing a JWF - Javaone 2011

    2/50

    Goals

    Define a Web Framework

    Categorize and understand what type of UI youre building

    Learn important decision making criteria

    Learn about Grails, GWT, Tapestry & Wicket

  • 8/3/2019 Choosing a JWF - Javaone 2011

    3/50

    Agenda

    What is a Web Framework?

    Costs of a poor choice

    Identifying your needs

    Comparison criteria

    The Frameworks

    Summary

    Questions

  • 8/3/2019 Choosing a JWF - Javaone 2011

    4/50

    Current Frameworks

    Action Framework DWR JSPWidget OpenEmcee SwingWeb

    Anvil Echo Jucas OpenXava Tapestry

    Aranea Expresso JWAA OXF TeaServlet

    Aurora fleXive JWarp Pustefix ThinWire

    Baritus Folium jWic Restlet Trimpath Junction

    Barracuda GWT jZeno RIFE Turbine

    Bento Groovy/Grails jZonic RSF Verge

    Bishop Helma Macaw Seam VRaptor

    Canyamo Jacquard Makumba Shocks Warfare

    Cassandra Jaffa Maverick Smile WebOnSwing

    Chiba Japple Melati SOFIA WebWork

    Chrysalis JATO Mentawai Spring MVC Wicket

    Click JFormular Millstone Strecks wingS

    Cocoon JOSSO MyFaces Stripes Xoplon

    Dinamica JPublish Nacho Struts ZK

    Dovetail JSF Niggle Struts 2 ztemplates

    Over 100 Frameworks

  • 8/3/2019 Choosing a JWF - Javaone 2011

    5/50

    What is a Web Framework?

    Modern Definition

    Component Definition/Interface/Metadata

    Unified event model with named or typed events

    Uses MVP or MVC

    Resource Management - Static Checking, Optimization,Obfuscation, Minification & Bundling

    Data Binding

    Authoring Styles - Interactive, Declarative or Programatic

    Stateless

    Polyglot Server Side

  • 8/3/2019 Choosing a JWF - Javaone 2011

    6/50

    What is a Web Framework?

    Server-SideRendering

    ClientRendering

    HybridRendering

    2000 2011

    Progression towards hybrid or client-only rendering

  • 8/3/2019 Choosing a JWF - Javaone 2011

    7/50

    What is a Web Framework?

    Server-Side

    Rendering

    Component & TemplateFrameworks

    Component tree or templaterendered to produce markup

    Ajax added after the fact Examples

    Started with Struts

    Webwork

    Spring MVC v1

    Tapestry 3

  • 8/3/2019 Choosing a JWF - Javaone 2011

    8/50

    What is a Web Framework?

    Component Frameworks Render tree exists in client or

    server side

    Tight coupling between client/server models

    Examples

    Tapestry5

    Hybrid

    Rendering

  • 8/3/2019 Choosing a JWF - Javaone 2011

    9/50

    What is a Web Framework?

    No Component Model on theserver

    Compiled into Javascript

    Stateless Server Side - RPC orREST using Spring or Guice

    Examples

    GWT

    Client

    Rendering

  • 8/3/2019 Choosing a JWF - Javaone 2011

    10/50

    Architecture Evolution - 1999

    Rendering

    Services

    Data Store

    JSP

    Bean

    1. Request

    4. Response

    3. Service Call2. Uses

    Browser Web Container Service Layer

  • 8/3/2019 Choosing a JWF - Javaone 2011

    11/50

    Architecture Evolution - 2001

    Browser Web Container Service Layer

    Rendering

    Services

    Data Store

    Controller

    View:

    JSP,

    Template,

    Etc

    Model

    Bean

    1. Request

    4. Response

    3. Service Call

    Dispatcher

    2. Invokes

  • 8/3/2019 Choosing a JWF - Javaone 2011

    12/50

    Architecture Evolution - 2004

    Browser Web Container Service Layer

    Services

    Data Store

    Intercepted Servet

    Service Facade

    Controller

    View:

    JSP,

    Template,

    Etc

    Model

    Bean

    Response

    Request

    Controller

    View:

    JSP,

    Template,

    Etc

    Model

    Bean

    1. Request

    4. Response

    3. Service Call

    Dispatcher

    2. Invokes

    Service Call

  • 8/3/2019 Choosing a JWF - Javaone 2011

    13/50

    Architecture Evolution - 2007

    Browser Web Container Service Layer

    Hybrid Component Framework

    Services

    Data Store

    Component

    Model

    Component

    View

    Component

    Controller

    components

    Component

    Controller

    Component

    View

    Component

    Model

    Renderer4. Response

    1. Request

    Request

    Response

    (Optional)

    2. Invokes Root

    3. Service Call

  • 8/3/2019 Choosing a JWF - Javaone 2011

    14/50

    Architecture Evolution - 2008

    Browser Web Container Service Layer

    Client Component Framework

    Component

    View

    Services

    Data Store

    Intercepted ServetService Facade

    2. Response

    1. Request

    6. Creates

    3. Service Call 4. Service Call

    Component

    Model

    Component

    Controller

    5. Creates7. Binds

  • 8/3/2019 Choosing a JWF - Javaone 2011

    15/50

    What if I choose poorly?

    Difficult for the stakeholders to understand and use

    End up writing lots of boilerplate

    No unified Ajax transport or free marshaling/unmarshaling

    Direct persistence to Session or Context

    Limited Documentation

    No unified event model

  • 8/3/2019 Choosing a JWF - Javaone 2011

    16/50

    What if I choose poorly?

    Configuration becomes difficult to manage when the app grows

    No way to debug the templates

    Ability for the view to be used as the controller

    JavaServer Pages (JSP) Technology/JSTL becomes anightmare to read when the page grows

    Templates may have a steep learning curve

  • 8/3/2019 Choosing a JWF - Javaone 2011

    17/50

    Defining your needs

    Am I building an application?

    How big is my application?

    What is my usage scenario?

    Is this likely to change?

    You are building for the future.

    Do I really need a 3-tier architecture?

    What is the size and competencies of my team?

  • 8/3/2019 Choosing a JWF - Javaone 2011

    18/50

    Sweet Spots

    Not a one size fits all game

    Some requirements may have diverging implementationswhich create trade-offs

    Different frameworks for different usage scenarios

    View (Read) only. Ex - storefront, blog, online bank, corporatewebsite

    Write only. Ex - shopping cart, signup process

    Both view and write

    Highly Interactive - CRM, Application builder, Storefront/Workflow builder, Trading/Banking system

  • 8/3/2019 Choosing a JWF - Javaone 2011

    19/50

    The Criteria: Traditional

    What does it take to write Hello World?

    Performance

    Declarative View stye

    Templates or JSP

    Speed of Development

    New - what is the learning curve?

    Existing - how much time does it take to add simple features?

    Agile - is change easy?

  • 8/3/2019 Choosing a JWF - Javaone 2011

    20/50

    The Criteria: Traditional

    Validation

    Internationalization

    Documentation

    Bookmark-ability and History Management

    Scalability

    Component List

  • 8/3/2019 Choosing a JWF - Javaone 2011

    21/50

    The Criteria: Advanced

    AJAX support

    Integrated or after the fact

    Does it rely on external tools

    View language

    Java programming language, EL, OGNL, Multiple

    Community

    Active, continual development

    Maturity Push based or Pull based

    3-tier support - Spring and hibernate

  • 8/3/2019 Choosing a JWF - Javaone 2011

    22/50

    The Criteria: Advanced

    Client/Server Javascript language

    Is there tight coupling between the languages

    Does another part of the company use the framework?

    Do your developers have experience with it?

    Does it have an Archetype

    How many Jobs are there on Dice or Linkedin

    Error report clarity

    Post-redirect pain

  • 8/3/2019 Choosing a JWF - Javaone 2011

    23/50

    The Frameworks

  • 8/3/2019 Choosing a JWF - Javaone 2011

    24/50

    Grails

  • 8/3/2019 Choosing a JWF - Javaone 2011

    25/50

    Grails

    Uses Groovy

    Uses a distributed MVC - Controllers are URL addressable

    Classes are recompiled dynamically - refresh to see changes

    Uses GSPs - Templates like JSP

    No Component Metadata

  • 8/3/2019 Choosing a JWF - Javaone 2011

    26/50

    Grails

    Who Uses it?

  • 8/3/2019 Choosing a JWF - Javaone 2011

    27/50

    Grails

    //Groovystatic String dojoTable(Binding scriptBinding, params)

    def id = "${params.id}"

    def res = new StringBuffer(""" dojo.require("dojo.topic");

    ...""")

  • 8/3/2019 Choosing a JWF - Javaone 2011

    28/50

    Grails

    Client/Server Renderer Server

    AJAX On your own

    View Type Declarative, Programatic

    Framework Type Request (Pull)

    Community Large

    3 Tier F/W support Yes

    Friendly URLs No

    License Apache 2.0

  • 8/3/2019 Choosing a JWF - Javaone 2011

    29/50

    Grails

    Pros Cons Hot-deploy

    Simple configuration

    Closures

    Integrates Spring andHibernate

    Nice form builder

    Way faster than Rails

    Slow compared to nativeframeworks

    Ajax isnt built in

    No friendly errors/stacktraces

  • 8/3/2019 Choosing a JWF - Javaone 2011

    30/50

    Tapestry

  • 8/3/2019 Choosing a JWF - Javaone 2011

    31/50

    Component Metadata Framework

    Semi-static page structure

    Simple configuration - Smart defaults, easy customization

    Hot Redeploy of Classes/Markup- Refresh to see changes

    Component Metadata is namespaced HTML

    Simple rendering event model

    Built-in resource bundling

    Form builder from POJOs Polyglot server-side

    Tapestry

  • 8/3/2019 Choosing a JWF - Javaone 2011

    32/50

    Who Uses it?

    Tapestry

  • 8/3/2019 Choosing a JWF - Javaone 2011

    33/50

    Tapestry

    //Java Controllerpublicabstractclass SignIn extends BasePage {

    @Persist() publicabstract String getUserName(); publicabstractvoidsetUserName(String userName);

    public ILink signinButtonListener(IRequestCycle cycle) {//button click listener...}

  • 8/3/2019 Choosing a JWF - Javaone 2011

    34/50

    Tapestry

    Client/Server Renderer Both

    AJAX Drop-Dead simple

    View Type Declarative & Programatic mix

    Framework Type Component

    Community Large

    3 Tier F/W support Built-in

    Friendly URLs Yes

    License Apache 2.0

  • 8/3/2019 Choosing a JWF - Javaone 2011

    35/50

    Tapestry

    Pros Cons

    Uses annotated HTMLtemplates

    Hot-deploy Simple configuration

    First class AJAX support,and lots of it

    Nice form builder

    No API backwardscompatibility betweenmajor versions

  • 8/3/2019 Choosing a JWF - Javaone 2011

    36/50

    Wicket

  • 8/3/2019 Choosing a JWF - Javaone 2011

    37/50

    Wicket

    Flexible Component Framework

    Runtime component loading

    Annotated HTML templates

    Hot Redeploy - refresh to see changes

    Provides excellent support for controlling markup in Java

    Statically typed - makes for easy refactoring in your IDE

    Hot redeploy of component markup

  • 8/3/2019 Choosing a JWF - Javaone 2011

    38/50

    Wicket

    Who Uses it?

  • 8/3/2019 Choosing a JWF - Javaone 2011

    39/50

    Wicket

    //Definitionpublicclass Login extends WebPage {

    public Login(){add(loginPanel);}

    publicvoidonSubmit(){login();setResponsePage(new HomePage());

    }

    }

    // Usageadd(new LoginPanel("login", login);

  • 8/3/2019 Choosing a JWF - Javaone 2011

    40/50

    Wicket

    Client/Server Renderer Both

    AJAX Drop-Dead simple

    View Type Declarative & Programatic mix

    Framework Type Component

    Community Large

    3 Tier F/W support Built-in

    Friendly URLs Yes

    License Apache 2.0

  • 8/3/2019 Choosing a JWF - Javaone 2011

    41/50

    Wicket

    Pros Cons

    Annotated HTMLTemplates

    Excellent documentation Components can be

    extended

    Everything is done inJava

    Stateful by default

    Not a lot of developers

  • 8/3/2019 Choosing a JWF - Javaone 2011

    42/50

    GWT

    G (G )

  • 8/3/2019 Choosing a JWF - Javaone 2011

    43/50

    Google Web Toolkit (GWT)

    Java API and Widgets for writing RIAs

    Provides abstraction layer on top of DOM API

    Simple RPC, REST service integration and RequestFactory

    Compiler/Worker pipeline

    Source to Source optimizing compiler Compiler compiles to a browser and a locale

    Resource bundling and processing for static content

    Download the application code on demand

    Declarative UI builder in an IDE

    Browser Independent

    Polyglot back-end

    G l W b T lki (GWT)

  • 8/3/2019 Choosing a JWF - Javaone 2011

    44/50

    Google Web Toolkit (GWT)

    Who Uses it?

    G l W b T lkit (GWT)

  • 8/3/2019 Choosing a JWF - Javaone 2011

    45/50

    Google Web Toolkit (GWT)

    public class MyApp implements EntryPoint, ... {

    public voidonModuleLoad()Resources.INSTANCE.CSS().ensureInjected();

    topPanel.addText(Messages.INSTANCE.basicTitle()); rightPanel.add(list); mainPanel.add(table);

    Window.enableScrolling(false);Window.setMargin(0);

    DockPanel outer = new DockPanel();outer.add(topPanel, DockPanel.NORTH);outer.add(leftPanel, DockPanel.EAST);outer.add(mainPanel, DockPanel.CENTER);

    outer.addStyleName(Resources.INSTANCE.CSS().dock());

    History.addValueChangeHandler(this);

    RootPanel.get().add(outer);

    G l W b T lkit (GWT)

  • 8/3/2019 Choosing a JWF - Javaone 2011

    46/50

    Google Web Toolkit (GWT)

    Client/Server Renderer Client

    AJAX Drop-Dead simple - RPC, RF or REST

    View Type Interactive, Declarative, Programatic

    Framework Type Component

    Community Large - 27K Members

    3 Tier F/W support Built-in

    Friendly URLs Yes

    License Apache 2.0

  • 8/3/2019 Choosing a JWF - Javaone 2011

    47/50

    S

  • 8/3/2019 Choosing a JWF - Javaone 2011

    48/50

    Summary

    Not all frameworks are equal

    Understand and outline your needs

    Find a few that look like they meet those needs

    Use the criteria and evaluate

    Dont take my word for it, try a Hello World of your own

    F M I f ti

  • 8/3/2019 Choosing a JWF - Javaone 2011

    49/50

    For More Information

    Me

    [email protected]

    These slides

    http://bit.ly/TS21280

    The Frameworks

    http://grails.org

    http://code.google.com/webtoolkit

    http://tapestry.apache.org http://wicket.apache.org

    http://apache.tapestry.org/http://code.google.com/webtoolkit/http://grails.codehaus.org/http://bit.ly/TS-21280http://wicket.apache.org/http://wicket.apache.org/http://apache.tapestry.org/http://apache.tapestry.org/http://code.google.com/webtoolkit/http://code.google.com/webtoolkit/http://grails.codehaus.org/http://grails.codehaus.org/http://bit.ly/TS-21280http://bit.ly/TS-21280mailto:[email protected]?subject=Javaone%202011mailto:[email protected]?subject=Javaone%202011
  • 8/3/2019 Choosing a JWF - Javaone 2011

    50/50

    THANK YOU

    Choosing a Java Based Web

    Framework: A Comparison

    Richard Pack

    Salesforce.com

    TS-21280