• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Apache Wicket Web Framework
 

Apache Wicket Web Framework

on

  • 6,348 views

Apache Wicket Web Framework Presentation

Apache Wicket Web Framework Presentation

Statistics

Views

Total Views
6,348
Views on SlideShare
6,311
Embed Views
37

Actions

Likes
4
Downloads
161
Comments
1

4 Embeds 37

http://www.slideshare.net 34
http://webcache.googleusercontent.com 1
http://www.linkedin.com 1
https://www.linkedin.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Apache Wicket Web Framework Apache Wicket Web Framework Presentation Transcript

    • Apache Wicket Java Web Application Framework St. Louis - Java User’s Group Luther Baker • September 2009
    • What is Wicket? • Web Application Framework • Component-based Framework • Wicket 1.4 is Java 1.5+ compliant
    • Where does Wicket fit? User Presentation Tier (Wicket) Shared Business Tier Objects Integration Tier
    • Request / Response JSP Request / Response home request jsp browser server response
    • Model 2 (MVC) Struts, Spring MVC, Stripes home jsp request browser server response home controller
    • Advantages of R/R • Rendering views is generally quite fast • Development can leverage existing tag libraries • Recruiting developers may be easier • Modern implementations have good support for DI and IoC frameworks
    • Disadvantages of R/R • Controller implementations must explicitly consider multiple concurrent users and threads • Controllers generally work literally in terms of HTTP requests and responses • Controllers often explicitly manage state • Not strictly Object Oriented • The programming model is skewed
    • The Impedance Mismatch The Programming Model • Programming in Java - do we regularly focus on how the JVM manages object instances and variables? • Generally, website development requires an understanding of the HTTP protocol. IE: manually managing state within and across requests forces front end handlers to be protocol specific.
    • What if ... ? • What if we considered a page ... a Page? • What if we considered a button ... a Button? • And upon clicking a button, handled an onClick event? • What if web-development resembled Swing or event-driven development? • What kind of framework could possibly enable this?!
    • Enter ... Wicket • Component-based framework • Instead of creating a controller, servlet or action class ... create a Page • Place components on said Page and define how each component reacts to user input • Build the Page in Java to manage HTML page elements ... not the other way around
    • The Component Model The Underlying Abstraction • Graphic elements are laid out in HTML while their actual representation, behavior and implementation is defined in Java • A DOM style parent/child approach • An event-driven programming model • You wonder ... “How can such an abstraction sit on top of HTTP?”
    • Web App Config web.xml <web-app> <context-param> <param-name>configuration</param-name> <param-value>development</param-value> </context-param> <filter> <filter-name>WebApplication</filter-name> <filter-class> org.apache.wicket.protocol.http.WicketFilter </filter-class> <init-param> <param-name>applicationClassName</param-name> <param-value>mypackage.HelloWorldApplication</param-value> </init-param> </filter> <filter-mapping> <filter-name>WebApplication</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app>
    • Wicket Config WicketApplication.java package mypackage; import org.apache.wicket.protocol.http.WebApplication; public class HelloWorldApplication extends WebApplication { public Class getHomePage() { return HelloWorld.class; } }
    • General Structure Markup (HTML’s Role) • Layout the element hierarchy • Style the elements Code (Java’s Role) • Mirror and implement markup’s element hierarchy • Event handling Properties Files (~Auxiliary Roles) • Literal strings and i18n
    • Hello World Markup <html> <body> <span wicket:id="message">Message goes here!</span> </body> </html> Java import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.markup.html.basic.Label; public class HelloWorld extends WebPage { public HelloWorld() { add(new Label("message", "Hello World!")); } }
    • Forms (HTML) Markup <html> <body> <span wicket:id="message">Message goes here</span> <form wicket:id="messageInputForm"> <input type="text" wicket:id="messageInput"/> <input type="submit" value="update"/> </form> </body> </html>
    • Forms (Java) Java public class HelloWorld extends WebPage { public HelloWorld() { IModel messageModel = new Model("Hello World!"); add(new Label("message", messageModel)); add(new MessageForm("messageInputForm", messageModel)); } private final class MessageForm extends Form { public MessageForm(String id, IModel model) { super(id); add(new TextField("messageInput", model)); } protected void onSubmit() { // nothing to do here as the model is automatically updated } } }
    • Component Family Component Page WebComponent Link Panel WebPage AjaxLink Button Checkbox TextArea Form TextField DropDown Label ...many more
    • Super Models • Static Model • Dynamic Model • Property Model • Compound Property • Loadable Detached
    • Basic Models Static Model public class HelloWorld extends WicketExamplePage { public HelloWorld() { add(new Label ("name", new Model(person.getName()))); } } Dynamic Model personForm.add(new RequiredTextField("personName", new IModel<String>() { @Override public String getObject() { return person.getName(); } @Override public void setObject(String value) { person.setName(value); } }));
    • More Models Property Model public PropertyModel(final Object modelObject, final String expression) class Person class Address { { private Address address; private String zip; public Address getAddress() public String getZip() { { return name; return zip; } } ... ... } } personForm.add(new RequiredTextField("zip", new PropertyModel<Person>(person, "address.zip")));
    • Demonstration WebPage Component • Java • HTML Subclass Master Page child & parent tags Custom Component • Java, HTML • Child components • Panel Superclass • Tags to include Event Handling • Original HTML • Ajax (Debug) • Generated Javascript • Submit handling
    • Ideally Suited For ... • Highly interactive apps • Help-Desk style ticketing applications and online Registration applications • Apps with lots of Forms and/or UI controls • Apps requiring seamless Ajax behavior • Apps simulating thick clients • Anytime an event programming model better suites the problem domain
    • Deeper Dive Maven Quickstart Archetype • An easy way to start with a simple, Mavenized, Wicket project Other Topics • More on Models, Sessions and Security • Unit Testing • Custom components • URL mapping, IoC Integration, Persistence ...
    • Wicket Resources Wicket Links • http://wicket.apache.org/ • http://wicketstuff.org/ • http://cwiki.apache.org/WICKET/ Wicket Books • Wicket in Action (Manning) • Pro Wicket (Apress)